HyperLink URLs, Images and Email Addresses

You can easily hyperlink URLs by using the <a href> HTML tag in formulas.

Example #1

This formula adds a hyperlink to the LastName field, using the EmployeeID field as a URL parameter passed to a “Show Employees” page.

= "<a href= '../Employees/ShowEmployees.aspx?Employees=" + EmployeeID +"'>" + LastName+ "</a>"

In order to see the field transformed into a hyperlink, several additional housekeeping actions are required.

Step 1:  Set the “HTML encode value” property for the control to False.  This ensures the “less than” and “greater than” symbols do not get encoded and will actually render as an image.

Step 2:  Set the “Maximum display length” property to something high such as 999999 so the text is not truncated.

Step 3:  Set the “Display threshold” property in the [Pop ups] section to something high so a popup is not displayed when your mouse hovers over the control.

Example #2

This example converts an Image control (Picture) on a Show Categories Table page into a hyperlink.

Step 1:  Drag two literal controls (asp:literal or GEN:LITERAL) from the Toolbox (ASPX & Other Controls tab) onto your page, placing one above the Picture control and the other below the Picture control.

Step 2: Rename the first and second literal to “OpenTag” and “CloseTag” respectively.

Step 3:  In the Formulas tab for the first literal control, enter this formula for the “Initialize display text” event:

= "<a href= '../Categories/ShowCategories.aspx?Categories=" + CategoryID +"'>"

Step 4:  In the Formulas tab for the second literal control, enter this formula:

= "</a>"

Step 5:  On the Property Sheet, change “Pop ups” to False to disable image popups.

Step 6: Rebuild and run your application.

Note: Splitting the formula between the two literal controls indirectly encloses the Picture control in an <a href> tag.

Example #3

This example converts an EmailAddress control into a hyperlink which opens Microsoft Outlook when clicked.

= "<a href='mailto:" + EmailAddress + "'>" + EmailAddress + "</a>"

See Also

Common Formula Examples