The HtmlAnchor class defines the methods, properties, and events for the HtmlAnchor control. This class allows programmatic access to the HTML <a> element on the server.
Object
Control
HtmlControl
HtmlContainerControl
HtmlAnchor
[Visual Basic] Public Class HtmlAnchor Inherits HtmlContainerControl Implements IPostBackEventHandler [C#] public class HtmlAnchor : HtmlContainerControl, IPostBackEventHandler [C++] public __gc class HtmlAnchor : public HtmlContainerControl, IPostBackEventHandler [JScript] public class HtmlAnchor extends HtmlContainerControl, IPostBackEventHandler
There are two ways to use the HtmlAnchor class. The first is for navigation: using the HRef property to define the location of the page to link to. The second is for post-back events: using the OnServerClick event to programmatically handle a user clicking a link text as an event raised on the server.
Namespace: System.Web.UI.HtmlControls
Assembly: System.Web.dll
[Visual Basic]
<html> <script runat=server> Sub AnchorBtn_Click(Source As Object, E as EventArgs) Message.InnerHtml = "Gotcha!" End Sub </script> <body> <form method=post runat=server> <a OnServerClick="AnchorBtn_Click" runat=server> Click here at your peril.</a> <h1> <span id="Message" runat=server></span> </h1> </form> </body> </html>
HtmlAnchor Members | System.Web.UI.HtmlControls Namespace | TBD