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>

Tim

A .NET, PHP, Marketing Guru authority, at least I hope I am. Reach me at tboland@gmail.com

18 thoughts on “ASP:HyperLink & Mailto

  1. Thanks mate.

    Somethimes sites like this solve a problem quicker than the tutorials.

    Good one saved me some time. Just make transition from asp to aspnet.

  2. I was also stucked in such problem in which my6 requirment was to have a Hyperlink as the last column of each row which moves to other page with the ID passed as the first column of the same Row.
    The given solution helped me:
    My working code is as:

    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='’ Text=”Update”>

  3. My requirement was to have a Hyperlink as the last column of each row which moves to other page with the ID passed as the first column of the same Row.The given solution helped me:My working code is as:
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='’ Text=”Update”>

    Thanks

  4. This didnt work right for me… see anything wrong?

    <asp:HyperLink NavigateUrl='’ Text=’dddd’ runat=”server” ID=”hlEmail”>

    Nothing shows up on the screen.

  5. I concur. I wen through the same iterations as you described, finally decided to use: NavigateUrl=” />. So, at least there is another way to accomplish the same thing.

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *