Tuesday, February 24, 2009

HyperLinkField doesn't like mailto

Just came across a "feature" of ASP.Net's GridView which I hadn't hit before.

If you have a HyperLinkField and point the DataNavigateUrlFields to a property or field that returns "mailto:x@y.com", it doesn't work. The entire link gets short circuited and only the text returns.

Apparently this is for security purposes, although it would be nice to be able to override it, EnableEventValidation-style (who knows - maybe you can and I've missed it...)

I thought you might be able to use BoundField, but it turns out that it HtmlEncodes everything, so it looks like a template is the one way to go...

No comments: