The ASP.net registration script dialog box does not display a blank page. [Method]

Source: Internet
Author: User

Many people are asking questions about the pop-up dialog box, which are summarized as follows:
I. Use js scripts
Response. Write ("<script> window. alert (\" Hello World \ "); </script> ");

Page. ClientScript. RegisterClientScriptBlock (GetType (), "", "<script> alert ('Enter the correct page'); </script> ");

2. Add the click attribute for the button:
My_Button.Attributes.Add ("onclick", "return confirm ('Are you sure you want to delete this record? ');");
3. Use MessageBox. Show ()
Reference: using System. Windows. Forms;
Note: This message will appear on the server.
4. This is the best of X:
The general solution is to use Response. Write to Write a script code to pop up the dialog box. The problem is that when the dialog box pops up, the page is blank. The method described here is to keep the page displayed while the dialog box is displayed!
Principle]
Place a hidden control on the page and put a script code at the end of the page. The script code checks whether the value of the hidden control is null. If not empty, a dialog box is displayed, otherwise, do nothing.

The background code modifies the value of the hidden control as needed. When the page is uploaded to the user, the final script code is executed and a dialog box is displayed.
[Note]

1. The hidden control must be an HTML control, otherwise javascript cannot be found.

2. You need to modify the value of the hidden control in the background code. The hidden control must be marked with runat = "server.

3. After the dialog box is displayed, remember to leave the value of the hidden control blank; otherwise, the value will pop up again during refresh.

4. The script code must be placed behind the hidden control; otherwise, it cannot be found.

[Implementation]

Page code (only list the body)

<Body MS_POSITIONING = "GridLayout">

<Form id = "Form1" method = "post" runat = "server">

<Asp: TextBox id = "manuInput" runat = "server"> </asp: TextBox>

<Asp: Button id = "Button1" runat = "server" Text = "dialog box"> </asp: Button>
<INPUT id = "passTxt" type = "hidden" runat = "server"> <! -Add hidden controls
</Form>
<Script language = javascript>
If (document. all ("passTxt"). value! = "")
{
Alert (document. all ("passTxt"). value );
Document. all ("passTxt"). value = ""; // This sentence cannot be dropped!
}
</Script>
</Body>

Background code (only list the response events of Button1)

Private void button#click (object sender, System. EventArgs e)
{
PassTxt. Value = manuInput. Text; // here manuInput. Text is the information to pop up.
}
This article from: Development Institute http://edu.codepub.com Source: http://edu.codepub.com/2010/0408/21745.php

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.