Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday 26 March 2016

HYPERLINK CONTROL PAGE NAVIGATION TECHNIQUE


Today in Engineer's World, we are discussing ASP.NET & C# query faced by a developer in very easy way. Posted By- +Manish Kumar Gautam +LIVE VIAR +ASP.NET SOLUTIONS 

Click imagination hunt to see latest Blogs


WHAT ARE THE DIFFERENT PAGE NAVIGATION TECHNIQUES?

Page navigation is a way by which we navigate a user from one webform to another webform.

1. Hyperlink control: Hyperlink control is a server control that is used to navigate one webform to any other webform or any external website. The navigation is done by the NavigationURL property where the URL is defined. The hyperlink control displays a clickable text or image which does not expose any server side events, so when the user clicks on a clickable text there is no server event like button click event or link button or image button control. This control also rendered as an HTML anchor <a> tag.

Properties of Hyperlink control:

(i) Text: Specify the clickable Text
(ii) NavigationURL: Specify the URL of the page
(iii) CssClass: Specify the clickable Text style
(iv) ImageURL: Specify the URL
(v) Target: Specify browser window to which the webform target to. Its value include- _blank, _self, _parent, _top, _search.

Practical Implementation:

Source code for navigationTechnique.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="navigationTechnique.aspx.cs" Inherits="navigationTechnique" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h1><u>Navigation Technique</u></h1>
            <br />
            <h3><u>Navigation by Hyperlink control</u></h3>
            <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/webform2.aspx">Click here to Redirect to Webform 2</asp:HyperLink>           
            <br />
            <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="http://www.liveviar.com">Click here to Redirect to LIVEVIAR</asp:HyperLink></div>
    </form>
</body>
</html>

Source code for webform2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="webform2.aspx.cs" Inherits="webform2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h3>This is Webform 2</h3>
        </div>
    </form>
</body>
</html>

Output:
Here, in the given below figure. The first link is redirecting to a webform of similar hosted website. While the second link is redirected to an external website.



For any query, comment us below.


Related Questions: -


Q-1 How to open webform in new tab or window?
Ans. There is a property called “target” which make the webform to open in a different tab or window.

Practical Implementation:

<asp:HyperLink ID="HyperLink3" runat="server" target="_blank" NavigateUrl="~/webform2.aspx">Click here to Redirect to Webform 2 using target value as blank</asp:HyperLink> 

Output:


This target property will tell the browser to open the webform2 in new window without changing the existing webform window. Read more about target values.

Q-2 Which HTML control it must look alike when Hyperlink control is rendered?
A) <link> tag
B) <a> tag
C) <redirect> tag
D) <span> tag

Ans- Option(B).
Explanation: Hyperlink renders to <a> anchor tag. Viewing the page source of the output screen we’ll find out that the code is rendered to anchor <a> tag.

Practical Implementation:

<asp:HyperLink ID="HyperLink3" runat="server" target="_blank" NavigateUrl="~/webform2.aspx">Click here to Redirect to Webform 2 using target value as blank</asp:HyperLink>

Output:



Click imagination hunt to see latest Blogs

Keep learning and sharing…

No comments:

Post a Comment

Featured post

Think that makes you rich and richer

 Napolean said: “You can think and grow rich, but if you can be brought up like most people with work and you won't starve, this wil...