HtmlAnchor.Name Property
Gets or sets the bookmark name defined in the HtmlAnchor server control.
[Visual Basic] Public Property Name As String [C#] public string Name {get; set;} [C++] public: __property String* get_Name(); public: __property void set_Name(String*); [JScript] public function get Name() : String; public function set Name(String);
Property Value
The bookmark name.
Remarks
Use this property to mark sections on a Web page with a name. This allows you to link to this section from anywhere on the same page. For example, you can provide a table of contents at the top of a page that will link directly to topics on the page.
To link to a marked section, use an HtmlAnchor control with the HRef property set to the name of the section, preceded by a # symbol (<a HRef= "#Topic1"/>).
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the Name property to mark different sections on the Web page, and link to them from a table of contents.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <body> <form method=post runat=server> <a Name="TOC"/> <h2>Table of Contents</h2> <a HRef="#Topic1">Topic 1</a><br> <a HRef="#Topic2">Topic 2</a><br> <a HRef="#Topic3">Topic 3</a><br> <br><br> <a Name="Topic1"/> <h3>Topic 1</h3> <br><br> Contents for first topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <a Name="Topic2"/> <h3>Topic 2</h3> <br><br> Contents for second topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br> <a Name="Topic3"/> <h3>Topic 3</h3> <br><br> Contents for third topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br><br> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <body> <form method=post runat=server> <a Name="TOC"/> <h2>Table of Contents</h2> <a HRef="#Topic1">Topic 1</a><br> <a HRef="#Topic2">Topic 2</a><br> <a HRef="#Topic3">Topic 3</a><br> <br><br> <a Name="Topic1"/> <h3>Topic 1</h3> <br><br> Contents for first topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <a Name="Topic2"/> <h3>Topic 2</h3> <br><br> Contents for second topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br> <a Name="Topic3"/> <h3>Topic 3</h3> <br><br> Contents for third topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br><br> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <body> <form method=post runat=server> <a Name="TOC"/> <h2>Table of Contents</h2> <a HRef="#Topic1">Topic 1</a><br> <a HRef="#Topic2">Topic 2</a><br> <a HRef="#Topic3">Topic 3</a><br> <br><br> <a Name="Topic1"/> <h3>Topic 1</h3> <br><br> Contents for first topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <a Name="Topic2"/> <h3>Topic 2</h3> <br><br> Contents for second topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br> <a Name="Topic3"/> <h3>Topic 3</h3> <br><br> Contents for third topic... <br><br><br><br><br><br><br><br><br><br><br> <a HRef="#TOC">Top</a><br> <br><br> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlAnchor Class | HtmlAnchor Members | System.Web.UI.HtmlControls Namespace