Tags

, , , ,


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.

Advertisements