ASP:HyperLink & Mailto

Recently I had a bit of trouble getting the HyperLink control to push out a mailto link in a Details View.

<asp:HyperLink NavigateUrl=’mailto:’ Text=’<%# Bind(”Email”) %> runat=”server” ID=”hlEmail”></asp:HyperLink>

 

This leaves a hyperlink but with a blank mailto - i.e. test@techtoolblog.com

So I assume if I stick in the bind (or eval) text to the Navigate URL we should be good to go:

<asp:HyperLink NavigateUrl=’mailto:<%# Bind(”Email”) %> Text=’<%# Bind(”Email”) %> runat=”server” ID=”hlEmail”></asp:HyperLink>

 

This gives me a link that is NOT clickable - If I view the source I see

<a id=”Details_hlEmail” href=”mailto:&lt;%#%20Bind(&quot;Email&quot;)%20%>”>test@techtoolblog.com </a>

 

My next guess is that this has something to do with formatting string, sure enough it is: This is the solution that ended up working for me:

<asp:HyperLink NavigateUrl=’<%# Bind(”Email”, “mailto:{0}”) %> Text=’<%# Bind(”Email”) %> runat=”server” ID=”hlEmail”></asp:HyperLink>

Written by Tim on August 15th, 2007 with no comments.
Read more articles on asp.net.



Related articles

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .