Ajax.ActionLink不会工作,如果确认是假的? [英] Ajax.ActionLink will not work if validation is false?
本文介绍了Ajax.ActionLink不会工作,如果确认是假的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@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;
}
}
这篇关于Ajax.ActionLink不会工作,如果确认是假的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文