[.net] ASP.NET
I'm not very good with ASP.NET but I'm trying to make an ASP project, so... I'm wondering how I would go about using a button click to load a new page. Thanks.
Hey jperalta,
You can hook the click event of the button on the server and transfer the control to another page. I don't have VS.NET in front of me so this probably won't compile (I'm not sure what language you're using, so this is in C#):
You could also do it on the client side by using the HTML-based form submit. I find that the above method is more in-tune with the ASP.NET methodology though. Make sure to use Server.Transfer() though instead of Response.Redirect(). Response.Redirect() sends an HTTP Redirect back to the client (which will require an extra round trip). Server.Transfer() on the other hand will transfer control directly on the server, so no round-trip is necessary (post button click of course :)).
Is this what you were looking for?
You can hook the click event of the button on the server and transfer the control to another page. I don't have VS.NET in front of me so this probably won't compile (I'm not sure what language you're using, so this is in C#):
// in page load (or through IDE)myButton.Click += new ClickEventHandler(this.myButton_OnClick);private void myButton_OnClick(object sender, ClickEventArgs e){ Server.Transfer("nextPage.aspx");}
You could also do it on the client side by using the HTML-based form submit. I find that the above method is more in-tune with the ASP.NET methodology though. Make sure to use Server.Transfer() though instead of Response.Redirect(). Response.Redirect() sends an HTTP Redirect back to the client (which will require an extra round trip). Server.Transfer() on the other hand will transfer control directly on the server, so no round-trip is necessary (post button click of course :)).
Is this what you were looking for?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement