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. Carsten says:

    Thank you for this code. It helped me a lot. Superb !

  2. Gavin says:

    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.

  3. James says:

    Helped alot, Brill coding!

  4. MatteoDb says:

    Great!!!!!

  5. Serge says:

    Thank you a lot!

  6. Love Poems says:

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

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

  8. really it’s very impressive post

    Sex Problems

  9. Abhinav says:

    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”>

  10. Abhinav says:

    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

  11. Lee says:

    This didnt work right for me… see anything wrong?

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

    Nothing shows up on the screen.

  12. John says:

    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!

  13. Marc says:

    This saved me a lot of time. Thanks.

  14. [...] ASP:HyperLink & MailtoTechToolBlog | TechToolBlog – 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:’ [...]

  15. 20170825yuanyuan says:

    dxwdwq

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>