Allow html in label control w/ anchor tag.

Answered
0
0

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.

 

Thoughts?

 

Thanks in advance,

 

Matthew

  • You must to post comments
Best Answer
0
0

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
Frank

  • You must to post comments
0
0

Thank you – this solution works great!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.