Page 1 of 1

Navigation Between Pages this tutorial shows you way of navigating between Pages

#1 theunborncoder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 123
  • Joined: 15-October 09

Post icon  Posted 10 December 2009 - 04:06 AM

Hi

In this tutorial we see the way of navigating between Pages

Asp.net provides 5 ways.
1.Using Server control
2.using Response.redirect method.
3.using Server.transfer method.
4.using Server.Execute method.
5.Using Javascript

we see one by one.
First Server Control

Server controls are like Hyperlink,Image Button & Link Button.
1)Hyperlink server control: It has NavigateUrl property. You can assign path where you want to mavigate whrn user click on hyperlink
When user click on hyperlink server control then

2)Link Button :
this server control has PostBackUrl property. here you have to assign path.
means when user click on linkButton then where user has to redirect or in other words which page have to display

3)Image Button:
this server control has PostBackUrl property. here you have to assign path.
means when user click on Image Button then where user has to redirect or in other words which page have to display

Second way Response.redirect
It Navigate to another page from code. This is equivalent to clicking a hyperlink
For Example:
Private Sub LinkButton1_Click(ByVal sender As System.Object, _
	ByVal e As System.EventArgs) Handles LinkButton1.Click
	Response.Redirect("Page1.aspx")
End Sub



Third way Server.transfer method
-Request Change on server itself
-End the current Web form and Starts executing a new Web form
-It keep Same Url it just changes the content of page.
It has only one Drawback
This method is only useful for .aspx pages that is only for Asp.net pages
its Syantax:
Server.Transfer("your path", preserveForm true/false)
  Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
' Transfer to another form, retaining ViewState
		Server.Transfer("your path", True)
	End Sub


Second parameter asks you. you want maintain viewstate or not

Fourth Way Server.Execute method
It Start executing a new Web form while still displaying the current Web form. The contents of both forms are combined.
-It keeps the same Url.

	Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
		Server.Execute("your path")
	End Sub


Last way that is Using Javascript
it contains window.Open script method
window.open method Display a page in a new browser window on the client.
You can write window.open in webforms's Source window. Here i am taking linkbutton & onclientclick i am writing code for open window.
<asp:LinkButton ID="LinkButton1" runat="server" 
			onclientclick="window.open("page2.aspx")">LinkButton</asp:LinkButton>


or you can select button. go to property window select onclient option and write window.open("Your Page")
This is all about navigating.

Thanks

Is This A Good Question/Topic? 1
  • +

Replies To: Navigation Between Pages

#2 3G Alarm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 31-May 09

Posted 16 January 2010 - 12:00 AM

i though that
Response.Redirect
was the only way th link to another page thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1