• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 592
  • 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.
0
sib_user
Asked:
sib_user
1 Solution
 
nfashawCommented:
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)
{
    Response.Redirect("~/Default.aspx");
}
0
 
sib_userAuthor Commented:
Thanks.  That's exactly what I needed!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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