Case study of ASP mode window

Source: Internet
Author: User

 

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:

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.