In the B/S structure, a single page is usually monotonous, and a button is added to make the form a modal window.
Instance: vs2010 sql2008
/// <Summary>
/// Click the button to bring up the form
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "E"> </param>
Protected void button#click (Object sender, eventargs E)
{
String url = "default2.aspx ";
// Showmodelwindow (URL, 315,800,100,100, this. Page); fixed window size
Showmodelwindow (this. Page, URL );
}
/// <Summary>
/// Display the modal window, which is not fixed
/// </Summary>
/// <Param name = "p"> navigation page address </param>
/// <Param name = "url"> the modal window address to be displayed </param>
Public void showmodelwindow (page p, string URL)
{
String csname = "showmodelwindowscript ";
Type cstype = P. GetType ();
Clientscriptmanager CSM = P. clientscript; // client script
If (! CSM. isstartupscriptregistered (cstype, csname ))
{
String cstext = string. format ("<script language = JavaScript> window. open ('{0}', 'newwindow', 'height = 700, width = 800, Top = 1, Left = 300, toolbar = No, menubar = No, scrollbars = Yes, resizable = Yes, location = No, titlebar = No, status = no'); </SCRIPT> ", URL );
CSM. registerstartupscript (cstype, csname, cstext, false );
}
}
/// <Summary>
/// Open the modal window to any size
/// </Summary>
/// <Param name = "p"> navigation page address </param>
/// <Param name = "url"> the modal window address to be displayed </param>
/// <Param name = "height"> height </param>
/// <Param name = "width"> width </param>
/// <Param name = "TOP"> distance from top </param>
/// <Param name = "Left"> sitting distance </param>
Public void showmodelwindow (string URL, int height, int width, int top, int left, page p)
{
String csname = "showmodelwindowscript ";
Type cstype = P. GetType ();
Clientscriptmanager CSM = P. clientscript;
If (! CSM. isstartupscriptregistered (cstype, csname ))
{
String cstext = string. format ("<script language = JavaScript> window. open ('{0}', 'newwindow', 'height = {1}, width = {2}, Top = {3}, Left = {4 }, toolbar = No, menubar = No, scrollbars = Yes, resizable = No, location = No, titlebar = No, status = no'); </SCRIPT> ", URL, height, width,
Top, left );
CSM. registerstartupscript (cstype, csname, cstext, false );
}
}
Effect: