You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a label control with allowHtml = true, and .text of "Please click here 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.
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.
Activity
itg-assistant commentedon Jun 12, 2026
Frank (ITG) answered 2018-02-27 08:48:08 UTC
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
itg-assistant commentedon Jun 12, 2026
Matthew Ferry answered 2018-02-28 01:46:55 UTC
Thank you - this solution works great!