1 / 10

Managing ASP.NET Navigation

Managing ASP.NET Navigation. Managing ASP.NET Navigation. Page Navigation means moving from one page to another (in the same or other sites) you can move between Web Forms in a variety of ways: hyperlinks Response.Redirect. Hyperlinks.

ataret
Download Presentation

Managing ASP.NET Navigation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Managing ASP.NET Navigation

  2. Managing ASP.NET Navigation • Page Navigation means moving from one page to another (in the same or other sites) • you can move between Web Forms in a variety of ways: • hyperlinks • Response.Redirect

  3. Hyperlinks • The simplest possible way to navigate from one Web Form to another. • HTML hyperlink control: ex) <a href="WebForm2.aspx">WebForm2</a> • HyperLink Web Server control: ex) <asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="WebForm2.aspx">WebForm2 </asp:HyperLink>

  4. Hyperlinks (Cont) • HTML hyperlink control has exactly the same effect as HyperLink Web Server control • since ASP.NET renders the HyperLink Web Server control as an HTML hyperlink control. • There is one key difference, though: the Web Server control can be programmed on the server side. ex)Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click HyperLink1.NavigateUrl = "WebForm3.aspx" End Sub

  5. Response.Redirect • Sometimes it's convenient to control the process of page navigation in code. • In other words, the web application sometimes needs to move from one page to another without asking a user to press on a certain hyperlink. • The Response.Redirect method causes the browser to connect to a specified URL.

  6. Response.Redirect (Cont) • When the Response.Redirect() method is called, it creates a header response. • When the browser receives this response from the server, it uses this header information to generate another HTTP request to the new URL • Ex) Response.Redirect(“WebForm2.aspx”)

  7. Passing variables between pages • You often need to pass variable content between your aspx webforms in context of Asp.Net • For passing variables content between pages ASP.NET gives us several choices. • One choice is using QueryString property of Request Object.

  8. Passing variables between pages • To pass variables and their contents to a certain page using QueryString, you have to associate them to the page URL Address. Ex) http://localhost/MySite/Webform2.aspx?id=10&name=Ali • This html addresses use QueryString property to pass values between pages. • In this address you send 3 information. • Webform2.aspx this is the page your browser will go. • id=10 you send a id variable which is set to 10 • name=Ali you send a name variable which is set to Ali

  9. Passing variables between pages • (?) starts your QueryString • and (&) is used between variables. • The page receiving the variables could access them using Request.QueryString() method. • Ex) to retrieve the content of the variable (name) of the previous URL, we write: • Request.QueryString(“name”) • Which will return “Ali”

  10. Passing variables between pages • Advantages of this approach • It is very easy. • Disadvantages of this approach • QueryString have a max length, If you have to send a lot information this approach does not work. • QueryString is visible in your address part of your browser so you should not use it with sensitive information. • QueryString can not be used to send & and space characters. • Solution : Replace space with %20 and & with %26 for example

More Related