Asp. NET Popup dialog box

Source: Internet
Author: User

Self-written window pops up:
Page.registerclientscriptblock ("alert""<script>alert (' two times password inconsistent, Please re-enter! ') </script>");

"Here's how to find it online"

During the development of the ASP, it is often necessary to give the user prompt information, such as whether "Operation succeeded", "OK" or "Cancel" operation:

(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:

Example:
public System.Web.UI.WebControls.Button btndelrow;btndelrow.attributes.add ("onclick ""return confirm (' OK to delete? '); "

(2) Click on the link on the page, pop up a dialog box prompt is "OK" or "Cancel" action, in the Page_Load () event, you want to give a confirmation prompt to add the properties of the button:

LINK.ATTRIBUTES.ADD ("onclick""return confirm (' Do you want to perform this operation? '); ");

(3) For a page to complete an action, a popup dialog box prompts whether "Operation succeeded":

Response.Write ("<script>alert (' Delete succeeded! ') </script>"

(4) allow an ASP. NET server control to issue a client script block in the Page:

 Public Virtual voidRegisterStartupScript (stringKeystringscript); Example:if(! This. IsStartupScriptRegistered ("Hello"))     This. RegisterStartupScript ("Hello","<script>alert (' Hello! ') </script>");

Popup dialog (the other party method):

The OK dialog box pops up:

Response.Write ("<script language=javascript>alert (' Message! ');</script>");

Popup "OK" dialog box, click on the jump page:

Response.Write ("<script language=javascript>alert (' Message! '); Window.navigate ('. /index.aspx ');</script>");

Pop up the OK and Cancel dialog boxes and click OK to do the following:

Method One: In the Page_Load event, write button1.attributes["OnClick"]= "Javascript:return confirm (' Are you sure you want to delete it? '), and then write your execution code in the Button1_onclick event.
Method Two: Write directly in the Button1_onclik event
Response.Write ("<Script Language=javascript>if (Confirm (' are you sure you want to delete it? '){window.navigate ('dodelete.aspx') );}  </Script>"); Method two need to jump to another page to perform operations, a little more cumbersome than the method, but how to use to see the specific situation.

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.