HtmlAnchor control
ASP.NET HtmlAnchor Control
HTML server control
Definition and usage
HtmlAnchor control Controls the <a> element. In HTML, the <a> element is used to create hyperlinks. Hyperlinks can link to bookmarks or other web pages.
Attributes
Attributes | Description |
---|---|
Attributes | Return all attribute name and value pairs of the element. |
Disabled | Boolean value indicating whether to disable the control. The default is false. |
HRef | The URL of the link. |
id | The unique id of the control. |
InnerHtml | Set or return the content between the opening tag and closing tag of this HTML element. Special characters are not automatically converted to HTML entities. |
InnerText | Set or return all text between the opening tag and closing tag of this 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 (such as the title attribute of the img element). |
Visible | Boolean value indicating whether the control is visible. |
Example
HTMLAnchor
In this example, we declared two HtmlAnchor controls in the .aspx file ( Remember to nest the control within the HtmlForm control). We then modify the URL, target, and title of the 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 many events understood by ASP.NET.
HTML Server Control