Fineui Tips (4) Close the form those things (another 24 professional HD large image)

Source: Internet
Author: User

Objective

The window control in Fineui is often used as a selection, new, or edited content. While closing the window control has a lot of tricks, understanding these tips can help you develop your project quickly.

How to close the window control

The first question is how to close the window control, the most obvious way is the close icon in the upper right corner. Overall, there are three ways:

    1. ESC key (in the case where the window control's page takes focus, pressing the ESC on the keyboard will close the active form)
    2. Close icon in the upper-right corner of the form
    3. User-defined Close button

The first two ways do not have to say, then how to customize the Close button? There are two ways of doing this:

  1. button disables postback, registering the close script when the page is initialized
     1  <  f:button  id  = "Btnhideinclient"   CssClass  = "inline"   Text  = "Hide form (client code)"   Enablepostback  = "false"  2   runat  = "Server"  >  3  </ f:button  >  
    1 protected void Page_Load (object  sender, EventArgs e)2{3     if (!  IsPostBack)4    {5         Btnhideinclient.onclientclick =  Window2.gethidereference (); 6     }7}8  
  2. Button postback, set the form hidden property in the postback event,
     1  <  f:button  id  = "Btnhideinserver"   Text  = "hidden form (server-side code)"   runat  = "Server"   OnClick  = "Btnhideinserver_click"  >  2   F:button  >  
    1 protected void Btnhideinserver_click (object  sender, EventArgs e)2{3     true; 4 }

    or register the shutdown script:

    1 protected void Btnhideinserver_click (object  sender, EventArgs e)2{3     Pagecontext.registerstartupscript (Window2.gethidereference ()); 4 }

Of course, the button here is the same as the window control on the same page.

For another common scenario, the window control that enables the IFRAME, how do the buttons located inside the IFRAME page close the window control in the parent page?

Obviously, we can't get an instance of the window control from within the IFRAME page!

It doesn't matter, Fineui provides the ActiveWindow class to handle this common problem:

1 protected void Btnsavecontinue_click (object  sender, EventArgs e)2{3     Pagecontext.registerstartupscript (Activewindow.gethidereference ()); 4 }

How to close a form

The closed form mentioned earlier is simply closed and does not do any other processing. In fact, Fineui provides three ways to close a form:

    1. Direct shutdown: The script returned by the Gethidereferene method mentioned earlier
    2. Close the form, and then postback the page where the form is located, triggering the close event of the window control: You can use the built-in Gethidepostbackreference method
    3. Close the form, and then refresh the page where the form is located: You can use the built-in Gethiderefreshreference method

Go back to "how to close the form" described earlier, obviously the first two methods of closing (ESC, upper-right corner of the close icon) cannot use the Gethide***reference method, how to do?

Fineui also provides a Closeaction property for the window control, with the possible values Hide,hidepostback and Hiderefresh, respectively, corresponding to the above method.

Take a look at an example:

  1. Initial display
  2. Click the close icon in the upper right corner to trigger the close event

    This behavior is controlled by the Closeaction property of the window control and looks at the label of the control:
    1 <F:windowID= "Window2"Width= "650px"Height= "300px"Icon= "Tagblue"Title= "form"Hidden= "true"2 enablemaximize= "true"Enablecollapse= "true"runat= "Server"enableresize= "true"3 Ismodal= "false"closeaction= "Hidepostback"OnClose= "Window2_close"Layout= "Fit">4 </F:window>

    Event handling code in the background:

    1 protected void Window2_close (object  sender, Windowcloseeventargs e)2{3     Alert.showintop ("The form is closed. Parameter:"" none "  : e.closeargument)); 4 }

    Closeaction cannot define a return parameter, so it shows "none" Here!

  3. Click "Hide form with postback parameters" on the page to trigger the Close event, at which point the page appears

    The response script for this button is registered when the page is initialized, as shown below (note how the parameters are set in):
    1 protected void Page_Load (object  sender, EventArgs e)2{3     if (!  IsPostBack)4    {5         Btnhideinclient2.onclientclick = Window2.gethidepostbackreference ("btnHideInClient2"); 6     }7 }

Similarly, for the iframe-enabled window control, the close form processing of the button inside the IFRAME, corresponds to several methods of ActiveWindow:

    1. Activewindow.gethidereference
    2. Activewindow.gethidepostbackreference
    3. Activewindow.gethiderefreshreference

Close the confirmation dialog box for the form

This feature may not be known to many people, but there is a strong practicality.

Simple description: The window control that enables the IFRAME, and if any form fields within the IFRAME page change, a confirmation box pops up when the form is closed.

The goal is to prevent users from entering the form content, not yet come and save, a mistake to turn off the pop-up form.

    1. Page Initial display
    2. Enter any value in the Digital input box and click the Close icon in the upper-right corner to pop up the confirmation dialog box
    3. Empty the value in the Digital input box (that is, revert to its original state), and then click the Close icon in the upper-right corner to close the form directly

The above actions are controlled by the Enableconfirmonclose property of the window control (false by default), and the following is the label definition for this window instance:

1 <F:windowID= "Window1"Hidden= "true"Enableiframe= "true"runat= "Server"Enableconfirmonclose= "true"2 enablemaximize= "true"enableresize= "true"Height= "450px"Width= "800px"Title= "Form One">3 </F:window>

For the Close button on the above page, the behavior is consistent with the close icon in the upper-right corner, but this consistency is also considered controlled, to see the script for the Close button:

1 protected void Page_Load (object  sender, EventArgs e)2{3     if (!  IsPostBack)4    {5         Btnclose.onclientclick =  Activewindow.getconfirmhidereference (); 6     }7 }

Summary of this chapter

This article describes three ways to close the window control (ESC, close icon, custom), and the processing of three Fineui definitions (hidden, hidden, post-postback, and refreshed after hiding). For the Close button within the IFRAME, Fineui provides ActiveWindow to generate a shutdown script. A fineui built-in property Enableconfirmonclose is also introduced to control whether the Close Form confirmation dialog box pops up.

Source Code and online sample

The source code of all articles in this series can be downloaded by yourself: http://fineui.codeplex.com/

Online Example:

    1. Http://fineui.com/demo/#/demo/window/window.aspx
    2. Http://fineui.com/demo/#/demo/iframe/window.aspx

If this article has inspired you or help, please hit " good text to top ", support the original, support-stone!

24 Professional Edition HD large image

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.