• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

HyperLink Control Question

How can I dynamically change the "NavigateURL" property of the HyperLink control?

I'm using the built-in html "mailto:johndoe@hotmail.com" functionality.
This forces the user's default email client to handle the message with a pre-loaded addressee.
So, obviously you can see why I would want to change the addressee (NavigateURL property) on the fly with this control.

No javascript, please.

Thanks in advance.
1 Solution
you can access NavigateURL property in your code behind...

HyperLink1.NavigateURL = "mailto:" + "YourAddress@hotmail.com"

protected System.Web.UI.WebControls.HyperLink myLink;
myLink.NavigateURL = "mailto:johndoe@hotmail.com";

OR if that doesn't work, then you may need to use a plain old Html control

protected System.Web.UI.HtmlControls.HtmlAnchor myLink;
myLink.Attributes["href"] = "mailto:johndoe@hotmail.com";

I'm not entirely sure whether a HyperLink control can do a mailto. But one of these two solutions should do what you need.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now