Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 4 field in web form and trying to insert in database after successfull insertion i want to show alert message using ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txtname.Text + "')", true);


function


function Display(name) {
alert(name;:::Inserted successfully;);

}

but when i compile it is showing error as "The type or namespace RegisterStartUpScript does not exist in the namespace Scriptmanager(are you missing an assembly reference")
i have added all refernce

C#
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
Posted

On ASPX PAGE

ASP.NET
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    function Display(name) {
        alert(name + ':-  Insert Successfully');
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    
    
    
    </form>
</body>
</html>




On ASPX.CS PAGE


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('"+txtbox.Text+"')", true);
    }
}




Please Try It it is working ..
 
Share this answer
 
Comments
Sachin MCA2012 10-Nov-13 5:55am    
i WANT TO SHOW MESSAGE AFTER DATA INSERTED SUCCESSFULLY ON ADD BUTTON
Arif Ansari Code 10-Nov-13 23:35pm    
Dear Sachin You can try this code on Button event .
i did show working on page load you can implement on this code
hi sachin mca2012,

I checked that arif ansari's code is working f9 you can go with following as well,

C#
protected void Button1_Click(object sender, EventArgs e)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "callit()", true);
        
     }


and put below code in script tag in head tag

XML
<script  type="text/javascript">
       function callit()
       {
           alert("call successfull");
       }

   </script>


in button click event put your all data saving code before this register script if you data insertion will not be success this code execution will not go to this line..
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900