Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET HtmlAnchor Control

ASP.NET HtmlAnchor Control


HTML Server Controls HTML Server Controls


Definition and Usage

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


property

property Description
Attributes Returns all attribute name and value pairs of the 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 opening and closing tags of this HTML element. Special characters are not automatically converted to HTML entities.
InnerText Sets or returns all text between the opening and closing tags of this HTML element. Special characters are automatically converted to HTML entities.
Name The name of the anchor.
OnServerClick The name of the function executed when the link is clicked.
runat Specifies that this 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 (such as the title attribute of an img element).
Visible A Boolean value that indicates whether the control is visible.

Example

HTMLAnchor
In this example, we declare two HtmlAnchor controls in the .aspx file (remember to nest the controls inside the HtmlForm control). Then we modify the URL, target, and title of this HtmlAnchor control 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 understands.


HTML Server Controls HTML Server Controls