@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.
}
}
我想是这样上面。 OnBegin不neccesary做到这一点。可能是另一种解决方案。
I want something like above. OnBegin is not neccesary to do it. May be another solutions.
感谢。
OnBegin
应该这样做。简单地返回真
或假
取决于你是否要执行控制器动作与否:
OnBegin
should do it. Simply return true
or false
depending on whether you want to execute the controller action or not:
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.
alert('alerting some message');
return false;
}
else {
// Go to controller with parameters.
return true;
}
}