Asp.net Modal Dialog Box

Source: Internet
Author: User

Modal Dialog Box in Asp.net

Finally, I started writing B/S. Program . Today I encountered a problem: how to handle the modal dialog box. The specific requirements are as follows: click "add" on the selection page to bring up the modal dialog box. After adding a record in the dialog box, select "OK" to close the dialog box, update the data in the table on the home page.
There are many discussions on the modal dialog box on the Internet. I tried it for a day and found a better solution:
1. displayed dialog box: JScript Add the following to the script file:

Function Openeditwin (frmwin, width, height ){ VaR Me; // Pass the window object of the parent page as a parameter to the dialog box, so that the dialog box can manipulate the automatic refresh of the parent page. Me = Window; // The dialog box is displayed. Window. showmodaldialog (frmwin, me, 'dialogwidth = ' + Width + 'Px; dialogheight = ' + Height + 'Px; help: No; Status: no ')}

Call in C:

Cmdadd. Attributes. Add ( " Onclick " , " Javascript: openeditwin (' " + Session [ " Showform " ] + " ', 540,400) " );

Many methods are implemented using response. Write or registerstartupscript, but they all have problems, such as the blank page when the dialog box is displayed and the pop-up dialog box when the page is refreshed. In the dialog box, add:
FunctionOnsubmit ()//Force this window to submit {Document.form1.tar get="_ Self";}

2. Close the dialog box

Response. Write ( " <Script language = 'javascript '> " ); Response. Write ( " Window. Close () " ); Response. Write ( " </SCRIPT> " );

3. After the dialog box is closed, execute the update operation and add it to the closing event of the dialog box:

Response. Write ( " <Script language = 'javascript '> " ); Response. Write ( " Window. Close () " ); Response. Write ( " </SCRIPT> " );

4. Update table data on the home page. In the "add" button, addCode.

Session ["showform"] is the aspx file name in the dialog box. The content is very simple. Some text boxes are designed on the page for users to enter relevant information, as well as the "OK" and "cancel" buttons, when the "OK" button is selected, save the data in the text box to the database, and close the dialog box. If the "cancel" button is selected, the operation is canceled. I did a test according to your method and found that when you click the button in the pop-up dialog box, a non-modal page is always displayed, and the displayed content is the same as that in the pop-up dialog box. Why?
========================================================== ==================
Add
<Head>
<Title> </title>
<Base target = _ Self>
</Head> finally started to write the B/S program. Today I encountered a problem: how to handle the modal dialog box. The specific requirements are as follows: click "add" on the selection page to bring up the modal dialog box. After adding a record in the dialog box, select "OK" to close the dialog box, update the data in the table on the home page.
There are many discussions on the modal dialog box on the Internet. I tried it for a day and found a better solution:
1. displayed dialog box: JScript Add the following to the script file:

Function Openeditwin (frmwin, width, height ){ VaR Me; // Pass the window object of the parent page as a parameter to the dialog box, so that the dialog box can manipulate the automatic refresh of the parent page. Me = Window; // The dialog box is displayed. Window. showmodaldialog (frmwin, me, 'dialogwidth = ' + Width + 'Px; dialogheight = ' + Height + 'Px; help: No; Status: no ')}

Call in C:

Cmdadd. Attributes. Add ( " Onclick " , " Javascript: openeditwin (' " + Session [ " Showform " ] + " ', 540,400) " );

Many methods are implemented using response. Write or registerstartupscript, but they all have problems, such as the blank page when the dialog box is displayed and the pop-up dialog box when the page is refreshed. In the dialog box, add:
FunctionOnsubmit ()//Force this window to submit {Document.form1.tar get="_ Self";}

2. Close the dialog box

Response. Write ( " <Script language = 'javascript '> " ); Response. Write ( " Window. Close () " ); Response. Write ( " </SCRIPT> " );

3. After the dialog box is closed, execute the update operation and add it to the closing event of the dialog box:

Response. Write ( " <Script language = 'javascript '> " ); Response. Write ( " Window. Close () " ); Response. Write ( " </SCRIPT> " );

4. Update table data on the home page. In the "add" button, add the table update code.

Related Article

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.