Page navigation techniques in asp.net-Hyperlink


Page Navigation


In this part we will study what is page navigation technique? Why use them? Basically there are different types of page navigation technique in ASP.NET but each technique has its own importance and benefits, and which page-navigation technique should be used depends on the current scenario of the application.

Page Navigation technique in the ASP.NET
1. HyperLink Control
2. Rsponse.Redirect
3. Server.Execute
4. Cross Page PostBack
5. Window.Open

Page-Navigation use to navigate a page by suggested path. Not only you navigate a page you can also apply website navigation.

In real time in web application we need to navigate a page from one page to another page, but if not properly navigate than through an error at runtime (like 404 error).

Hyperlink


The easiest way to navigate from one web page to another web page with an ASP.NET hyperlink control.

Hyper link control maintain the history, Hyper link control is a like html anchor tag, which is use to navigate same web-server or different server.

Hyperlink does not expose server side events, so when user click on a HyperLink, there is no server side event to intercept the click where button click event is intercept.

We create Page-Navigation.aspx page in ASP.NET and drag and drop HyperLink control in this page from toolbox.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page-Navigation.aspx.cs" Inherits="AspDotNets.Page_Navigation" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:HyperLink ID="hyperlink1" runat="server" NavigateUrl="~/Default.aspx" Text="Navigate to another page"></asp:HyperLink><br/>
<a href="~/Default.aspx" title=""> Navigate to another page</a>
    </form>
</body>
</html>
You can see in the above example we link Default.aspx page in the NavigateUrl property.

We also developed an anchor tag (a href link), which also move to the same page (Default.aspx) when click on anchor tag as we said above hyperlink control of ASP.NET is similar to anchor tag of html.

We create another webform to which we want to navigate through Hyperlink and we name it Default.aspx.

In the above example we show, this is the one of the simple and good website (paste link of website path in navigateUrl) or page navigation method through which we simply navigate a page from one page to another page.



0 comments:

Post a Comment