How to redirect from one ASP.NET page to another

后端 未结 8 1993
感动是毒
感动是毒 2020-12-19 08:48

How do I redirect from one ASP.NET page to another (\"Webform2.aspx\") by means of a button?

相关标签:
8条回答
  • 2020-12-19 09:36

    set PostBackUrl property of button, like this :

    button1.PostBackUrl= "Webform2.aspx";
    
    0 讨论(0)
  • 2020-12-19 09:38

    Well there are lot of ways. Response.Redirect, Server.Transfer, Javascript call to the page.

    Javascript call is required when u have no server side actions for the button. onclick="javascript:window.location.href = Webform2.aspx?id='<%=Request.QueryString["id"]%>'"

    Server.Transfer will do a re-direct at server side. i.e, The browser will still show after the response from webform2. Webform1.aspx will re-direct the request to webform2 and webform2 will give the req. (Req = 1, Res = 1)

    Response.Redirect: webform1 will send a response asking the browser to make a new request to webform2. In this case, the browser will change the url as it is making a new req to webform2.(Req = 1 + 1, Res = 1+1)

    There is one more way, form.submit() if you are interested. The traditional html form submit.

    Forgot to mention the best of all, the cross-page postback with PostBack url.. http://aspdotnetcode.source-of-humor.com/TipsAndTricks/General/CrossPagePostbackAspNetCrossPagePostback.aspx

    0 讨论(0)
提交回复
热议问题