asp.net.ph

HtmlAnchor.Name Property

System.Web.UI.HtmlControls Namespace   HtmlAnchor Class


Sets or retrieves a named location, or bookmark, within a Web document.

Syntax


Inline <a name = strName ... >
Script HtmlAnchor.Name [ = strName ]

Property Value


strName String specifying the bookmark name.

The property is read/write with no default value.

Remarks

Use this property to mark locations on a Web page with a name, so that they can be the destination of another link. For example, you can provide a table of contents at the top of a page that will link directly to topics within the page.

To specify a named location that can be used as the destination of other links:

<h3><a name="intro">Introduction</a></h3>

This allows users to link to this location from within the same or from a different page.

To link to a named location within the same page, use an HtmlAnchor with the HRef property set to the name of the section, preceded by a hash [ # ] symbol, like

<a href="#intro">Back to Intro</a>

To link to a named location in another page, use an HtmlAnchor with the HRef property set to the URL of the requested page, followed by the name of the section preceded by a hash [ # ] symbol, like

<a href="page1.apx.#intro">See Intro</a>

The value of the name property must be unique within the scope of the current document. Note that this property shares the same functionality as the ID property in the sense that the ID also serves to designate a named location at the start tag of any control.

It is permissible to use both name and id attributes to specify an anchor; when both attributes are used on a single anchor, however, their values must be identical.

Authors should consider the following issues when deciding whether to use name or id for an anchor name:

  • The name property allows richer anchor names, including any valid chracter entities.
  • Some older browsers do not support anchors created with the id property.
  • The id property can act as more than just an anchor name ( e.g., stylesheet selector, processing identifier, etc. ).

Example

This example shows how to use the Name property to designate different locations on the Web page, and link to them from a table of contents.

<a name="TOC"/>
<h2>Table of Contents</h2>
<a href="#Topic1">Topic 1</a><br>
<a href="#Topic2">Topic 2</a><br>

<p></p>

<a name="Topic1"/>
   <h3>Topic 1</h3>
   . . .
   Contents for first topic ...
   . . .
   <a href="#TOC">Top</a><br>

<a name="Topic2"/>
   <h3>Topic 2</h3>
   . . .
   Contents for second topic ...
   . . .
   <a href="#TOC">Top</a><br>
See Also

HtmlAnchor Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph