Visual Studio Tutorials

      
       Search my site for your answer

    How to create a link from 1 page to another in your asp.net website

This is a short a sweet example of the code needed to link 2 pages in your website. So lets say you have a page called Default.aspx and you want to create a link from there to a page called "online-times-tables-chart.aspx"

For this exaple we will use a button on your webpage to hold the link.

This is how you do it

 

So put a button a your page then double click on the button to take you to code view like below. You will see the same code as below. The only difference will be the button number. As you can see mine says Button13, yours will say what ever (it's no big deal)

linking 2 pages in asp.net

All you need to do is add a simple line of code, the code is

Response.Redirect("~/online-times-tables-chart.aspx")

You enter this code between the "Protected Sub" line and the "End Sub" line so your code will look like the exaple below.

Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
Response.Redirect("~/online-times-tables-chart.aspx")
End Sub
End Class

Look at the screen print below.

links in asp page websites link one page to another

So that's it your done if this lesson helped you please leave feedback by clicking this link just to let others know.