[.net] ASP.NET

Started by
1 comment, last by jperalta 19 years, 6 months ago
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.
Advertisement
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#):

// 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?
Jason Olson - Software Developer[ Managed World ]
Thanks

This topic is closed to new replies.

Advertisement