What buttons need to be displayed in a message box where OK and cancel are displayed
MessageBoxButtons Messbutton = Messageboxbuttons.okcancel;
"Are you sure you want to exit?" "Is the display information for the dialog box," Exit System "is the title of the dialog box
By default, such as MessageBox.Show (Are you sure you want to exit?) ") displays only one OK button.
DialogResult dr = MessageBox.Show ("OK to exit?", "Exit System", Messbutton);
The code is as follows |
Copy Code |
if (dr = = DialogResult.OK)//If you click on the "OK" button { ...... } else//If you click the "Cancel" button { ...... } |
MessageBoxButtons specifies several constants to define which buttons will appear on MessageBox (from MSDN)
MessageBoxButtons Member:
Description of Member name
The Abortretryignore message box contains the abort, retry, and Ignore buttons.
The OK message box contains the OK button. Default
The Okcancel message box contains the OK and Cancel buttons. (as shown in the previous example)
The Retrycancel message box contains the retry and Cancel buttons.
The YESNO message box contains the Yes and no buttons.
Yesnocancel message box contains Yes, no and Cancel buttons
With some other wording
(1) Click on the button on the page, pop-up a dialog box prompts "OK" or "Cancel" operation, we use the button to add properties to complete:
Examples are as follows:
The code is as follows |
Copy Code |
Public System.Web.UI.WebControls.Button Btndelrow; BTNDELROW.ATTRIBUTES.ADD ("onclick", "return confirm (' OK to delete? ');");
|
(2) Click on the button on the page, pop-up a dialog box prompts "OK" or "Cancel" operation, select "OK" or "Cancel" to jump to the appropriate page:
examples are as follows:
code is as follows |
copy code |
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 a page completes an operation, a pop-up dialog box prompts whether "successful operation."
Examples are as follows:
The code is as follows |
Copy Code |
Response.Write (' Delete succeeded! ') ("<script>alert") </script> "); |
(4) For a page to complete an operation, a pop-up dialog box prompts whether the "successful operation" after the jump to a page.
Examples are as follows:
The code is as follows |
Copy Code |
Response.Write (' Delete success! ') ("<script>alert"); window.location.href = ' www.cnblogs.com ' </script> '); |
(5) Allow ASP.net server controls to emit client script blocks in Page:
The code is as follows |
Copy Code |
public virtual void RegisterStartupScript (string key,string script); |
Examples are as follows:
code is as follows |
copy code |
if (!this. isstartupscriptregistered ("Hello")) this. RegisterStartupScript ("Hello", "<script>alert") </script> "); |