We're in. NET program development process, often need to interact with the user information, such as whether to perform an operation is successful, "OK" or "Cancel", and choose "OK" or "Cancel" after the need to jump to a page, etc., the following is my common use of the dialog box summary, I hope to be helpful to everyone, You are also welcome to add.
(1) Click the button on the page, pop up a dialog box prompt is "OK" or "Cancel" action, we use the button to add properties to complete:
Examples are as follows:
Copy CodeThe code is as follows:
Public System.Web.UI.WebControls.Button Btndelrow;
BTNDELROW.ATTRIBUTES.ADD ("onclick", "return confirm (' OK to delete? ');");
(2) Click the button on the page, pop up a dialog box prompt is "OK" or "Cancel" action, select "OK" or "Cancel" to jump to the corresponding page:
Examples are as follows:
Copy CodeThe code is as follows:
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) for the page to complete an action, a popup dialog box prompts whether "Operation succeeded".
Examples are as follows:
Copy CodeThe code is as follows:
Response.Write ("<script>alert (' delete succeeded! ') </script> ");
(4) For a page to complete an action, a popup dialog box prompts whether the "operation succeeded" after jumping to a page.
Examples are as follows:
Copy CodeThe code is as follows:
Response.Write ("<script>alert (' delete succeeded! '); window.location.href = ' www.cnblogs.com ' </script> ');
(5) allow an ASP. NET server control to issue a client script block in the Page:
Copy CodeThe code is as follows:
public virtual void RegisterStartupScript (string key,string script);
Examples are as follows:
if (!this. isstartupscriptregistered ("Hello"))
This. RegisterStartupScript ("Hello", "<script>alert" (' Hello! ') </script> ");
(6) The following is a pop-up dialog box called the Class I organized:
Copy CodeThe code is as follows:
Using System;
Using System.Web;
Namespace ShowMessage
{
<summary>
A summary description of the MSG.
</summary>
public class ShowMessage
{
Public ShowMessage ()
{
//
TODO: Add constructor logic here
//
}
public static void ShowMessage (String strMsg)
{
System.Web.HttpContext.Current.Response.Write ("<script language= ' JavaScript ' >window.alert ('" +strmsg+ "); </script> ");
}
public static void ShowMessage (System.Web.UI.Page Page, String strMsg)
{
Page. Response.Write ("<script language= ' JavaScript ' >window.alert ('" +strmsg+ "');</script>");
}
public static void ShowMessage (String strMsg, String Url)
{
System.Web.HttpContext.Current.Response.Write ("<script language= ' JavaScript ' >window.alert ('" +strmsg+ "); window.location.href = ' +url+ ' </script> ');
}
public static void ShowMessage (System.Web.UI.Page page,string strMsg, String Url)
{
Page. Response.Write ("<script language= ' JavaScript ' >window.alert ('" +strmsg+ "); window.location.href = ' +url+ ' </script> ");
}
public static void Showconfirm (String strMsg, String Strurl_yes, String strurl_no)
{
System.Web.HttpContext.Current.Response.Write ("<script language= ' JavaScript ' >if (window.confirm ('" +strmsg+ "') {window.location.href= '" + Strurl_yes +
"'} else {window.location.href= '" + strurl_no + "'};</script>");
}
}
You may be interested in the article:
- ASP. GridView 72-like stunt
- jquery.uploadify Upload File plugin usage details for ASP.
- ASP. NET generates Excel and exports five implementations of the download
- Asp. NET Access denied solution summary for path "xxxxx"
- ASP. NET gets the code for the various properties (file name, parameter, domain name, etc.) of the current URL URL
- operation, writing, reading and operation of ASP.
- ASP. Interview written questions [with answers]
- Using jquery to pass complex JSON data to ASP.-modelbinder article
- ASP generation and Refresh and validation
- ASP. NET The system cannot find the file specified workaround
Asp. The basic implementation method of several popup box hints in net