If response. write ("<SCRIPT> alert ('error information'); </SCRIPT>"); click "OK", which may cause "dislocation" of the page ";
Encapsulate the code into a class (called pagehelper. CS), which can be conveniently called on other pages;
For example, you can call page. Alert (this, "") on other pages. The effect is the same as that of the above Code. Do you have to say something different? That is, this writing method is much more perfect than above.
You can also have the second parameter, that is, page. Alert (this, "Warning ~ ","~ /Default. aspx ");
/**
*
* Description: Page Assistant class. A warning dialog box is displayed;
*
* Design by: recall;
*
* Creation date:
*
**/
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. Web. UI;
Namespace newssystem. commonutility
{
Public static class pagehelper
{
Public static void alert (page objpage, string message)
{
String key = "alertmessage ";
String script = string. Format ("alert ('{0}')", message );
Objpage. clientscript. registerstartupscript (typeof (PAGE), key, script, true );
}
Public static void alert (page objpage, string message, string URL)
{
String key = "alertmessage ";
String script = string. Format ("alert ('{0}'); window. Location = '{1}';", message, URL );
Objpage. clientscript. registerstartupscript (typeof (PAGE), key, script, true );
}
}
}