I. Pop-up confirmation information (1--3)
1. response. Write ("<SCRIPT> alert ('background white! '); </SCRIPT> ");
In this method, the background is white when a message box is displayed.
2,
Page. clientscript. registerstartupscript (page. GetType (), "message", "<script language = 'javascript 'defer> alert (' the background is not white! '); </SCRIPT> ");
3,
//. Net enter the JS prompt statement in the post code (the background will not be white)
Page. clientscript. registerstartupscript (page. GetType (), "message", "<script language = 'javascript 'defer> alert (' added to the storage shelf successfully! '); </SCRIPT> ");
// Redirection
Page. clientscript. registerstartupscript (page. GetType (), "message", "<script language = 'javascript 'defer> alert (' congratulations, modification successful! '); Window. Location = 'default. aspx' </SCRIPT> "); similar to Ajax, the page is not refreshed !!!
Ii. Pop-up selection information
(1) click the button on the page and a dialog box is displayed, prompting whether to "OK" or "cancel". We can add attributes to the button to complete the operation:
Example:
Public System. Web. UI. webcontrols. Button btndelrow;
Btndelrow. Attributes. Add ("onclick", "Return confirm ('Are you sure you want to delete it? ');");
(2) click the button on the page to bring up a dialog box prompting "OK" or "cancel". Select "OK" or "cancel" to go to the corresponding page:
Example:
String strmsg, string strurl_yes, string strurl_no;
Response. Write ("<script language = 'javascript '> If (window. Confirm ('" + strmsg + "') {window. Location. href ='" + strurl_yes +
"'} Else {window. Location. href ='" + strurl_no + "'}; </SCRIPT> ");
(3) After completing an operation on the page, a dialog box is displayed, prompting whether the operation is successful ".
Example:
Response. Write ("<SCRIPT> alert ('deleted successfully! ') </SCRIPT> ");
(4) after you complete an operation on the page, a dialog box is displayed, prompting whether the operation is successful.
Example:
Response. Write ("<SCRIPT> alert ('deleted successfully! '); Window. Location. href = 'www .cnblogs.com' </SCRIPT> ");
(5) Allow ASP. NET Server controls to issue client script blocks in the page:
Public Virtual void registerstartupscript (string key, string script );
Example:
If (! This. isstartupscriptregistered ("hello "))
This. registerstartupscript ("hello", "<SCRIPT> alert ('Hello! ') </SCRIPT> ");