ASP.NET HtmlAnchorControl


HTML Server ControlsHTML Server Controls

Definition and Usage

The HtmlAnchor control is used to control the <a> element. In HTML, the <a> element is used to create hyperlinks. A hyperlink can link to a bookmark or another web page.


Properties

Property Description
Attributes Returns the name and value pairs of all attributes of this element.
Disabled A Boolean value that indicates whether the control is disabled. The default is false.
HRef The URL of the link.
id The unique ID of the control.
InnerHtml Sets or returns the content between the start and end tags of the HTML element. Special characters are not automatically converted to HTML entities.
InnerText Sets or returns all the text between the start and end tags of the HTML element. Special characters are automatically converted to HTML entities.
Name The name of the anchor.
OnServerClick The name of the function that is executed when the link is clicked.
runat Specifies that the control is a server control. Must be set to "server".
Style Sets or returns the CSS properties applied to the control.
TagName Returns the tag name of the element.
Target The target window to open.
Title The title displayed by the browser (for example, the title attribute of the img element).
Visible A Boolean value that indicates whether the control is visible.


Examples

HTMLAnchor
In this example, we declare two HtmlAnchor controls in a .aspx file (remember to nest the controls in an HtmlForm control). Then we modify the URL, target, and title of the HtmlAnchor controls in an event handler (an event handler is a subroutine that executes code for a given event). The Page_Load event is one of the many events that ASP.NET can understand.


HTML Server ControlsHTML Server Controls Other Extensions