• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 630
  • Last Modified:

ASP.net code to jump to a URL

I am trying to use an asp.net button onclick event to jump to URL.  I assign the script Go_To_Url to the button's onClick event but am at a lost as to which asp.net class method to call to effect the jump.  Please help.
1 Solution
If you're looking to have the user redirected to a new page when they click on a button, I'd suggest one of the following ways.

1. Set the PostBackUrl attribute on the button to the target page.
<asp:Button ID="Button1" runat="server" Text="button 1" PostBackUrl="~/Default.aspx" />

2. In the button's OnClick event, use the Response.Redirect method.
<asp:Button ID="Button2" runat="server" Text="button 2" OnClick="Button2_Click" />

protected void Button2_Click(object sender, EventArgs e)
sib_userAuthor Commented:
Thanks.  That's exactly what I needed!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now