Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why the error is giving "The name 'ScriptManager' does not exist in the current context" in the following line.How to define script manager


HTML
<html>
<head>
<title>Entry for notification</title>
<script type="text/javascript">
function Showalert(username) {
alert(username + ' details updated successfully.');
}

My HTML Code is given below
</head>
<body>
<script src="../nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image']}).panelInstance('area4');
new nicEditor({maxHeight : 400}).panelInstance('ta1');
});
</script>
<form  runat="server">
<textarea style="height: 100px;" cols="80" id="ta1"  runat="server"></textarea><br><br>
<asp:Button ID="b1" Text="Submit" OnClick="submit" runat="server"/>
</form>
</body></html>


My CS Code is given below

C#
<%@ Page validateRequest="false" Debug="True"%>
<%@Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.OleDb"%>
<script  runat="server" language="c#">
OleDbConnection con;
OleDbCommand com;
OleDbDataAdapter da;
DataSet ds;
string a1,st;

void page_Load(Object sender,EventArgs e)
{
con=new OleDbConnection();
con.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/nicedit/adv_web.mdb") + "";
con.Open();
ds=new DataSet();
string sql="select * from notification";
da=new OleDbDataAdapter(sql,con);
da.Fill(ds,"notification");
}
void submit(Object sender, EventArgs e)
{
con.Open();
com=con.CreateCommand();
com.CommandText="UPDATE notification SET notice = '" + ta1.Value + "' where id='" + 1 + "'";
int result= com.ExecuteNonQuery();
con.Close();
if(result==1)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Showalert('"+ta1.Value+"')", true);
}
}
</script>
Posted
Updated 15-Feb-12 22:30pm
v2
Comments
NikulDarji 16-Feb-12 4:31am    
pre tag added.....

1 solution

include following code inside the form
<asp:scriptmanager id="ScriptManager1" runat="server"/>
 
Share this answer
 
v2
Comments
Janardan Pandey 16-Feb-12 4:41am    
Error is giving: Unknown server tag 'asp:ScriptManager'
Herman<T>.Instance 16-Feb-12 4:49am    
place that line of code inside your form tags
Jeevitha royapathi 16-Feb-12 6:50am    
Use NameSpace "System.Web.UI" in cs page

and remove this code from design page
<asp:scriptmanager id="ScriptManager1" runat="server"/>
blue_developer 20-Sep-12 10:33am    
Thank you Jeevitha!!
That worked for me.
Cheers. ;]

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

  Print Answers RSS


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