The window popup implementation in ASP. NET, including the branch window. Asp. NET returns a summary of the previous page implementation method.

Source: Internet
Author: User
Tags close close

Return to the previous page of this stuff when we do the project is generally used to fill out the form after the confirmation, there is the original input data to modify or update the use, or because the site for the convenience of visitors and the intention to add an east, In general, the implementation of this function in the ASP is a button control to achieve, the implementation of a number of methods, today happens to be in the project to use this thing, I will be able to implement the "return to the previous page", "Return to the previous page" several methods summed up, for everyone to learn, please advise: In fact, to achieve this function is mainly to use the JavaScript scripting language! Method One: In the source code of the ASP. <input type= "button onclick=" Javascript:window.history.go (-1); " Value= "Return to previous page" > analysis: This is the use of HTML control, through an onclick event, called a method in JavaScript. This is the simplest, also applicable to static pages, ASP pages and so on. Method Two: Using Reponse.write () If you have a certain understanding of the ASP, then the Response.Write this thing will not be unfamiliar, method one is directly with the HTML page implementation, then this is in the background environment (this statement seems not very standard, hehe) Response.Write ("<script language=javascript>history.go ( -2);</script>) <a href=" # "onclick=" Javascript:history.back (); " > Return to previous </a> here is the value of 2 to be used, I personally think this is the case: because in the ASP. NET page, when you press a button, because the page will implement Page.postback, actually in this is the refresh of the page two times, we want the first time, so ... Method Three: Use Response.Redirect () or Server.Transfer () to add the IF (!) in the Page_Load.   IsPostBack) viewstate["Retu"]=request.urlreferrer.tostring (); In the Return button event, Response.Redirect (viewstate["Retu").     ToString ()); OrServer.Transfer (viewstate["Retu").    ToString ());        Brief analysis: Request.urlreferrer can get information about the URL that the client last requested, we should make a judgment if (viewstate["Urlreferrer"]!=null) when we use this Response.Redirect (viewstate["Urlreferrer").  ToString (); Else{response.write ("Sorry, current is the top page"); This makes it a little bit more important to note when using Request.urlreferrer: 1.    If the previous page uses the Document.location method to navigate to the current page, Request.urlreferrer returns a null value of 2. If you have a A, B, two pages, request a page directly in the browser and navigate to page B in the Page_Load event in page A, Request.urlreferrer returns NULL.  Because the page has not been initialized in the Page_Load event, the information on the current page cannot be logged, and navigating to page B will not be able to get information on the previous Page 3. Click the Refresh button does not change the Request.urlreferrer method four: This method is estimated to be very few people use, but I tried, but also very good oh, in the onclick event of the button, enter This.registerclientscriptblock (" E "," <script language=javascript>history.go ( -2);</script> "); You can return to the previous page method five: This method is also more troublesome, not recommended for everyone to use, This one seems to be inside the ASP. <a href=<%=request.servervariable ("Http_referre)%><asp:image id=" imageback "visible = True" imagurl= "previous page "runat=" Server "/></a>

1Reprint: http://www.cnblogs.com/xiaoli0414/articles/778980.html2 3  4 5 1. Window with confirmation and Cancel branch buttons6 7Place a server control to execute the Insert command in the Button1_onclick event of the server control. Add button1 to LoadPage (). Attributes.Add ("onclick","return confirm (' Confirm submit data? ');")8 9 then add the code you want to execute after confirming the button's Click event .Ten  One   A  - 2. A Simple reminder window -  theResponse.Write ("<script Language=javascript>alert ("Xxxxxxxxxxxx");</script>"); -  -   -  + 3. A popup or jump page based on a condition -  +    if(exceeding the limit) A  at   {  -  -Response.Write ("<script>if (Confirm (' over quota, do you want to continue? ') location= ' b.aspx '; else History.go ( -1);</script>");  -  -   }  -  in  Else -  to  {  +  -Response.Write ("<script>location= ' b.aspx ';</script>");  the  *  }  $ Panax Notoginseng stringStr="<script language= ' javascript ' >alert (' Provincial bureau data cannot be modified! ');</script>";  -  thePage.registerstartupscript ("DD", str);  +  A   the  + 4. window.close Close the window, do not eject the system prompt, close directly -  $When we use this method: Response.Write ("<script>window.close () </script>")  $ always prompt for what: you view the page to try to close the prompt -How do I remove a hint and close the form directly? - You can use the following methods: theResponse.Write ("<script>window.opener=null;window.close () </script>")  - only IE6 support.Wuyi opener as long as any value is set, no prompt will appear the  -  Wu What do I do if I close the parent form through a subform? - Subform (pop-up form): About In the same vein, you get: $Response.Write ("<script>window.opener.top.opener=null;window.opener.top.close () </script>")
View Code

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.