asp.net.ph

HtmlAnchor.HRef Property

System.Web.UI.HtmlControls Namespace   HtmlAnchor Class


Sets or retrieves the destination of the HtmlAnchor control.

Syntax


Inline <a href = strUrl ... >
Script HtmlAnchor.HRef [ = strUrl ]

Property Value


strUrl String specifying the URL target of the link.

The property is read/write with no default value.

Remarks

The HRef property on an HtmlAnchor control can refer to:

  • any valid URI
  • any valid anchor point or bookmark within a document, specified with either:
    • an anchor name attribute
    • or any object's id attribute.

When specifying an anchor, everything contained between the <a href ...> and the </a> tags defines the hyperlink to that address.

Example

The below example illustrates using the simple yet powerful databinding feature of ASP.NET.

Databinding with the HtmlAnchor enables authors to dynamically generate hyperlinks on a Web Forms page using values from given fields in a data source.

And when databinding is used within templates in list controls such as the <asp:Repeater>, <asp:DataGrid>, and <asp:DataList>, only a single declaration is needed to generate each hyperlink item in the list. Note that the method used in this sample not only generates the link text, but also the querystring parameter of the url, which determines what argument is passed along to each link.

<a href='<%# DataBinder.Eval ( Container.DataItem, "title_id", 
   "details_title.aspx?titleid={0}" ) %>'>
   <%# ( ( DataRowView ) Container.DataItem ) [ "title" ] %></a>

 Show me 

See Also

HtmlAnchor Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph