Asp.net| dialog box finally began to write the B/s program.
Today encountered a problem, how to deal with modal dialog box. The specific requirements are: on the selection page of the "Add" button, pop-up modal dialog box, add a record in the dialog box, select the "OK" button, close the dialog box, update the data on the Home page table.
There are a lot of discussions about modal dialogs on the web, and after a day of trying, find a better solution:
1, Display dialog box:
In the JavaScript script file, add:
function Openeditwin (frmwin,width,height)
{
var me;
Passes the parent page window object as a parameter to the dialog box so that the dialog box manipulates the parent page for automatic refresh.
me = window;
Displays a dialog box.
window.showModalDialog (Frmwin,me, ' dialogwidth= ' +width + ' px;dialogheight= ' +height+ ' Px;help:no;status:no ')
}
Called in C #:
CMDADD.ATTRIBUTES.ADD ("onclick", "Javascript:openeditwin ('" + session["ShowForm"] + "', 540,400)");
Many methods are implemented with Response.Write or registerstartupscript, but there are problems, such as when the page is blank when the dialog box is displayed, and the pop-up dialog box appears when the page is refreshed.
Add a JScript script to a dialog box
session["ShowForm" is the ASPX filename of the dialog box, the content is very simple, on the page design some text boxes, let the user input relevant information, as well as the "OK" and "Cancel" button, select the "OK" button to save the data in the text box to the database, and close the dialog box, The Cancel button cancels the action to close the dialog box.