We help IT Professionals succeed at work.

I can't seem to get a HyperLinkField to display & link to an email address, using either DataNavigateURLFormatString or even a separate field, to provide the 'mailto:' part

Last Modified: 2012-05-05
I have used HyperlinkFields before to display text from one field in a database whilst linking to the value held in another field. This has worked well with relative http links, e.g. /MyPage.aspx.

I would now like to use one to provide a clickable link to an email address. Of course, I am not storing the link protocol (mailto:) with the email addresses, so I need to add this on the web page, so the link doesn't try to link relatively to http://www.mywebsite.com/currentfolderpath/Paul.Cutcliffe@somewhere.com.

Reading the documentation, I see that Microsoft have already thought to this & provided us with the DataNavigateUrlFormatString property, & the example they provide works well: page.aspx?id={0} provides a link to http://www.mywebsite.com/currentfolderpath/page.aspx?id=Paul.Cutcliffe@somewhere.com.

However, when I apply this logic to my requirements & change the DataNavigateUrlFormatString property to mailto:{0} , my hyperlink ceases to be a hyperlink at all. Looking at the generated HTML, it does this: <td><a>Paul.Cutcliffe@somewhere.com</a></td> - so there's a hyperlink, but it links to nowhere!

Does anyone know why this feature doesn't work with mailto: ?

As a workaround, I thought I'd add another column to the View in the database called EmailLink, consisting of:

'mailto:' + dbo.aspnet_Membership.Email

... which of course is the URL I want to link to. Then I set the DataNavigateUrlFields property to EmailLink, & the DataTextField property to Email. However, the result is the same - the email address looks like plain text rather than a hyperlink, although behind the scenes again there is a hyperlink linking to nowhere.

So does anyone know how I can make these email links work?

Watch Question

Top Expert 2005
This one is on us!
(Get your first solution completely free - no credit card required)


Excellent, thanks.

Interesting though - as soon as you convert it to a template field, it works, even though you change nothing else.

Is it a bug that it doesn't work without converting it to a template field, or what?

Anyway, no matter - problem solved, points awarded.

Thanks again.
Top Expert 2005

Having this functionality in a HyperLinkField used to exist, but the asp.net team disabled it as they felt it could be a potential security problem.  Personally I think they should leave all this security stuff to us, the developers, as we have no idea what they've disabled and what the haven't, and makes for figuring out issues like this rather difficult unless you can find someone who's been there.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.