Newlogo.gif (8646 bytes)Data Binding - creating hyperlinks from data fields

You can bind a database field to an <A.. (anchor, i.e. hyperlink) tag. The data is used to fill in the HREF value ( the hyperlink's target page) so the field in the database should contain valid URLs - this can, of course, include bookmarks and relative page references, such as "Page2.htm" and "#section2".

You still need to provide some displayable text between the <A..> and </A> tags. This can be another field from the database (i.e. a description of the web site), or it can be the URL field again, to create a hyperlink which shows its target URL as the click-me text, like this row defintion:

Example 1 - using two database fields to create each hyperlink

The table is bound to the data source object (via the <TABLE> tag), and has a single column. The <a..> tag's "datafld" attribute binds the anchor tag's href property to the database field "URL". Following the <A..> tag, as always, is the content to be displayed as clickable text (in blue underlined hyperlink format). This is a <SPAN>, which is bound to another database field, containing the name of the site whose URL is the target of this link. Then there's the </SPAN> terminator, and finally the </A> tag to terminate the hyperlink's clickable text.

HTML source:

<tr><td width="250"><a datafld="URL"><span datafld="Name"></span></a></td></tr>

Results::

Link


Example 2 - using the same database field for the hyperlink's target and clickable text.

The table is bound to the same data source object , and has a two columns. The first column contains a <DIV>, bound to the site name field in the database. The second column starts with an <A> tag, bound to the URL database field (whose valuiles fill its href properties). Then there's a <SPAN>, also bound to the URL field, so the clickable text is the hyperlink's target URL. Finally there are the </SPAN> and </A> terminators.

HTML: 

<tr><td><div datafld="Name"></div></td>

<td><a datafld="URL"><span datafld="URL"></span></a></td></tr>

Results:

Name Link



Back to Menu