Managing ASP.NET Navigation by uqg17706

VIEWS: 9 PAGES: 10

									Managing ASP.NET
   Navigation
 Managing ASP.NET Navigation
 Page  Navigation means moving from one
 page to another (in the same or other
 sites)

 youcan move between Web Forms in a
 variety of ways:
     hyperlinks
     Response.Redirect
                Hyperlinks
 Thesimplest 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>
              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
          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.
   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”)
 Passing variables between pages
 Youoften need to pass variable content
 between your aspx webforms in context of
 Asp.Net

    passing variables content between
 For
 pages ASP.NET gives us several choices.
     One choice is using QueryString property of
      Request Object.
    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
 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”
    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

								
To top