@Ajax.ActionLink("like", "Like", "Article", new { postId = Model.post.PostId, userName = User.Identity.Name }, new AjaxOptions { OnBegin = "OnBegin" }, new { @class = "like_link" })
function OnBegin()
{
if( true ) // value from client side. not returning value from server.
{
// I dont want to work the link. I want only alert message.
}
else
{
// Go to controller with parameters.
}
}
I want something like above. OnBegin is not neccesary to do it. May be another solutions.
Thanks.
OnBeginshould do it. Simply returntrueorfalsedepending on whether you want to execute the controller action or not: