Reputation: 437
I have a Ajax.ActionLink() which is as below. Onclick of which a partial view should load within the parent view. It is working fine. Now in order to give some other functionality it is required to call a javascript function on click of that Ajax.ActionLink(). I am not sure whether it is possible or not. I have two button btnSubmit and btnUpdate. Simply, I want to toggle "enable/disable" functionality through that Javascript function and nothing else.
@Ajax.ActionLink(item.profilename, "_CreateProfile", new { profileid = item.profileid }, new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "partialDiv" })
Need help...Any advice is welcome !!
Thanks!!
Upvotes: 4
Views: 7425
Reputation: 34895
The overloads of the Ajax.ActionLink
contain a parameter for additional htmlAttributes
to be rendered:
Ajax.ActionLink(string linkText,
string action,
object routeValues,
AjaxOptions ajaxOptions,
object htmlAttributes )
You can define a click handler in the htmlAttributes
:
@Ajax.ActionLink(item.profilename,
"_CreateProfile",
new { profileid = item.profileid },
new AjaxOptions { HttpMethod = "GET", InsertionMode = InsertionMode.Replace, UpdateTargetId = "partialDiv" },
new { onclick = "handler" })
Upvotes: 4