4
我想创建一个类似于Ajax.ActionLink
的帮助程序。我创建了一个帮手有了一些变化要做到这一点:如何为Ajax.ActionLink定制帮助程序
@helper AjaxLink(string innerhtml, string href, string targetId)
{
if (!string.IsNullOrEmpty(innerhtml))
{
if (href.Trim() == "#")
{
<a href="@(href)">
@MvcHtmlString.Create(innerhtml)
</a>
}
else
{
<a href="@(href)" data-ajax-update="#@(targetId)" data-ajax-mode="replace">
@MvcHtmlString.Create(innerhtml)
</a>
}
}
}
帮助我创建像一个链接:
<a href="ItemRegister?testTypeId=1" data-ajax-update="#pageId" data-ajax-mode="replace">
<i class="fa fa-sign-out"><span style="right: -47px;" class="icon-bg bg-orange"></span></i><span>Register </span>
</a>
但它不工作!它刷新页面,而不是填充目标
我做到了,但不是工作呢! –
但它在我的系统上工作得很好 – Behzad
哦,我忘了连接到'jquery.unobtrusive-ajax.js'。你是对的!谢谢 –