Allow html in label control w/ anchor tag.


If I have a label control with allowHtml = true, and .text of “Please click <a href=#here>here</a> to say hello world.”

How can I get the event – like a linkClicked event – if they click just the portion of the text that is the anchor (i.e. the regular click gets fired for non anchor parts of the text)

Is this possible?  The htmlPanel h as ElementClicked which works for this purpose, but I’d be interested in doing this for label controls in particular.




Thanks in advance,



  • You must to post comments
Best Answer

Hi Matthew,

this can be accomplished by using the role property and handling the MouseClick event.

Simply add a role attribute to the HTML hyperlink and query it as e.Role in your MouseClick event handler.
Please note that the Click event handle does not have any arguments, so you need to use MouseClick or MouseDown.

With using different role properties you could also have multiple links in a label and handle each link separately.

Hope that helps.

Best regards

  • You must to post comments

Thank you – this solution works great!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.