Solution of error in Response.Write output JS script in Ajax
Ajax 3.5 is not altered. Later tried to Scriptmanager.registerstartupscript (UpdatePanel1, typeof (UpdatePanel), "AAA", "<script >alert (' Data add success! ') </script>, True); The last true in is changed to Scriptmanager.registerstartupscript (UpdatePanel1, typeof (UpdatePanel), "AAA", " <script>alert (' Data add success! ') </script> ", false); Write a generic message prompt class below.
public class MessageBox
{
Private HttpContext mycontext = null;
Public MessageBox (HttpContext currentcontext)
{
Mycontext = CurrentContext;
}
<summary>
customizing pop-up window Content
</summary>
<param name= "MSG" ></param>
public void Show (String msg)
{
MyContext.Response.Write ("<script>alert (' + msg + ');</script>");
Scriptmanager.registerstartupscript ((System.Web.UI.Page) Mycontext.currenthandler, typeof (System.Web.UI.Page), " AAA "," <script>alert (' "+ msg +" ');</script> ", false);
}
<summary>
Customize pop-up window content and move to a new page
</summary>
<param name= "MSG" > Custom message </param>
<param name= "Url" > A new page to go to </param>
public void Show (String msg,string Url)
{
MyContext.Response.Write ("<script>alert (' + msg +"); Web effects: location= ' "+url+" ';</script> ");
Scriptmanager.registerstartupscript ((System.Web.UI.Page) Mycontext.currenthandler, typeof (System.Web.UI.Page), " AAA "," <script>alert (' + msg + '); javascript:location= ' "+ Url +" ';</script> ", false);
}
<summary>
Customize pop-up window content, customize whether to close the current page
</summary>
<param name= "MSG" ></param>
<param name= "Close" ></param>
public void Show (String msg, bool close)
{
if (Close)
{
MyContext.Response.Write ("<script>alert (' + msg +"); Javascript:window.close ();</script> ");
Scriptmanager.registerstartupscript ((System.Web.UI.Page) Mycontext.currenthandler, typeof (System.Web.UI.Page), " AAA "," <script>alert (' + msg + '); Javascript:window.close ();</script> ", false);
}
Else
{
MyContext.Response.Write ("<script>alert (' + msg + ');</script>");
Scriptmanager.registerstartupscript ((System.Web.UI.Page) Mycontext.currenthandler, typeof (System.Web.UI.Page), " AAA "," <script>alert (' + msg + '); Javascript:window.close ();</script> ", false);
}
}
}