How do I redirect from one ASP.NET page to another (\"Webform2.aspx\") by means of a button?
set PostBackUrl property of button, like this :
button1.PostBackUrl= "Webform2.aspx";
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