Add click event through Html.PropertyFor method

ZZ
ZZ
Vote:
 

Hi,

We are using @Html.PropertyFor(m => m.LeftColumnLinks) for generating links. LeftColumnLinks property is of type LinkItemCollection.

Is it possible to add click event on the generated anchor tag ?

#302769
Jun 01, 2023 7:49
Vote:
 
#302773
Edited, Jun 01, 2023 8:43
Vote:
 

Html.PropertyFor should create unique id that you can 
> document.getElementById("uniqueId").addEventListener("click", myJsFunction);

#302774
Jun 01, 2023 8:45
Scott Reed - Jun 01, 2023 8:51
JS is an option, although I don't believe there's any unique IDs added on (unless custom) when rendered in the non edit view but you can pass an id value or class as a parameter the Html.PropertyFor attributes collection
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.