HtmlAnchor

HtmlAnchordisposable

System.Web.UI.HtmlControls (system.web.dll)class

This class represents the <A> anchor tag in HTML, which provides a hyperlink. The linked text is contained inside the tag and can be accessed through the InnerHtml property. You can also programmatically change the linked page (HRef), the target frame (Target), and the window title for the target (Title). Even if the HRef property is not set, you can handle the ServerClick event and use a Response.Redirect statement to load a different page. The HtmlAnchor control also supports data binding to the HRef and InnerHtml properties.

You can use an anchor tag to mark a bookmark in a page, in which case you set the Name property but not the HRef property. In this case, you don't need to include any text inside the tag, as in <a Name="TopicName"/>. To make a link to this bookmark, add #TopicName at the end of the URL requesting this page.

public class HtmlAnchor : HtmlContainerControl, System.Web.UI.IPostBackEventHandler {
// Public Constructors
   public HtmlAnchor( );
// Public Instance Properties
   public string HRef{set; get; }
   public string Name{set; get; }
   public string Target{set; get; }
   public string Title{set; get; }
// Protected Instance Methods
   protected override void OnPreRender(EventArgs e);            // overrides System.Web.UI.Control
   protected virtual void OnServerClick(EventArgs e);
   protected override void RenderAttributes(System.Web.UI.HtmlTextWriter writer); // overrides HtmlContainerControl
// Events
   public event EventHandler ServerClick;
}

Hierarchy

System.Object System.Web.UI.Control(System.ComponentModel.IComponent, System.IDisposable, System.Web.UI.IParserAccessor, System.Web.UI.IDataBindingsAccessor) HtmlControl(System.Web.UI.IAttributeAccessor) HtmlContainerControl HtmlAnchor(System.Web.UI.IPostBackEventHandler)



    Part I: Introduction to ASP.NET
    Part III: Namespace Reference
    Chapter 40. The System.Web.UI.MobileControls Namespace
    Chapter 42. The System.Web.UI.WebControls Namespace