Jump to content
  • Advertisement
Sign in to follow this  
jperalta

[.net] ASP.NET

This topic is 5393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!