Asp. The basic implementation method of several popup box hints in net

Source: Internet
Author: User
Tags httpcontext

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.