Solved code to jump to a URL

Posted on 2010-01-04
Last Modified: 2013-11-15
I am trying to use an 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 class method to call to effect the jump.  Please help.
Question by:sib_user
    LVL 4

    Accepted 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)

    Author Closing Comment

    Thanks.  That's exactly what I needed!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now