HyperLink Control


We can use HyperLink control when we need to provide navigation to other page. For only navigation specially when you don’t need any server side processing to do we can prefer HyperLink control over LinkButton.

<asp:HyperLink ID="hlNewDate" runat="server" ToolTip="[#]Click to see news" Text=’<%# Eval("DateHeader") %>’ Target="_blank"
NavigateUrl=’<%# Eval("LinkUrl") %>’ CssClass="nyHeaderFont"></asp:HyperLink>

 

So, now you can navigate directly with also the Target property. Which has some enumeration options:

_blank

Renders the content in a new window without frames.

_parent

Renders the content in the immediate frameset parent.

_search

Renders the content in the search pane.

_self

Renders the content in the frame with focus.

_top

Renders the content in the full window without frames.

But in case If we use LinkButton

<asp:LinkButton ID="lnkNewsDate" runat="server" ToolTip="[#]Click to see news" Text=’<%# Eval("DateHeader") %>’
                                      PostBackUrl=’<%# Eval("LinkUrl") %>’  CssClass="nyHeaderFont"></asp:LinkButton>

As LinkButton doesn’t have any property as Target and NavigateUrl.

Here it will directly postback to the page so you can’t have an option to open a new window and keep you current page open. Yet, you can do so by the writing JavaScript even code for "onClientClick.

Posted on August 4, 2010, in ASP.net, Asp.net User Control and tagged , , , , . Bookmark the permalink. Leave a Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 54 other followers