SaaS CMS has officially launched! Learn more now.

Add click event through Html.PropertyFor method



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 ?

Jun 01, 2023 7:49
Edited, Jun 01, 2023 8:43

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

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.