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:
Add the following to the JScript 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 #:
Add. 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:
Function Onsubmit () // 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, perform the update operation.
In the Close event dialog box, add:
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.