Asp. NET page Pop-up window method

Source: Internet
Author: User
Tags generator net window root directory
Because the project uses the pop-up window, or is called the simulation window, this time has studied, the solution many, for instance, window.open (), Window.showdialog (), uses the layer simulation, the frame +div+javascript ....

With window.open (), the disadvantage of this method is that it will be blocked by the browser or related software. With layer simulation, if you want to implement a more complex window, it is more difficult, the third method is to synthesize all the knowledge of Web page production, can provide a good solution. However, the third implementation is difficult to accomplish for people who don't have enough knowledge of JavaScript. Some time ago in the online shopping, found a good solution: Greybox. After repeated research, it was found that Greybox can almost complete all pop-ups (although it seems to be less supportive of frames in the framework). For ease of use, I encapsulate greybox as a control. Now paste the usage out:

1. Documents involved: GreyBox.dll (Dynamic Library) Greyboxloader.aspx,greyboxloader.aspx.cs (frames for loading web pages), GB_STYLES.CSS (style sheet)

2. Add Files:

① Add references GreyBox.dll to Bin folder

② add Greyboxloader.aspx,greyboxloader.aspx.cs to the project's root directory.

③ add gb_styles.css file to imges/css/folder

3. Call Method:

① Reference Control:

Add code at the top of the page: <%@ Register assembly= "Greybox" namespace= "Greybox" tagprefix= "CC1"%>

To add code between <form></form>: <cc1:greybox id= "Geybox1" runat= "Server" ></cc1:GreyBox>

② Load CSS File:

Htmllink Myhtmllink = new Htmllink ();

Myhtmllink.href = "Images/css/gb_styles.css";

MYHTMLLINK.ATTRIBUTES.ADD ("rel", "stylesheet");

MYHTMLLINK.ATTRIBUTES.ADD ("type", "text/css");

PAGE.HEADER.CONTROLS.ADD (Myhtmllink);

③ Register Popup event (take button as an example):

This. BUTTON1.ATTRIBUTES.ADD ("onclick", "Return Gb_showcenter" (' Modify password ', ' echangepw.aspx ', 200,390) ");

Parameter description of Gb_showcenter (' title ', ' URL ', Height,width) method:

Title: Caption of pop-up window

URL: Web address or Web page filename

Height: Pop-up window Heights

Width: Pop-up window widths

In this way, click on the Button1 to pop a window.

4. Methods:

To close a window:

Response.Write ("< script language=javascript>parent.parent.gb_hide ();</script>");

To submit and close a window:

A frame of case (IFRAME)

Response.Write ("< script language=javascript>parent.parent.document.forms (0). Submit ();</script>");

No frame of case

Response.Write ("< script language=javascript>top.window.document.forms (0). Submit ();</script>");

Description: All the resources of Greybox are owned by the original author, and they are interested to visit their website. The above has a detailed introduction, of course, you can also discuss with me, I would like to share with you.

PS: Last month, the end of the release of the code generator, was intended to upload the source to friends as soon as possible, but, because recently in a project, plus that code generator for colleagues to use, found some bugs and put forward some requirements, I am ready to rewrite.



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.