如何在asp.net mvc中通过ajax更新特定的div数据
问问题
6414 次
2 回答
3
您可以查看UpdateTargetId属性:
控制器:
public ActionResult SomeAction()
{
// you could return a PartialView here if you need more complex HTML fragment
return Content("<span>some content</span>", "text/html");
}
看法:
<div id="result"></div>
<%= Ajax.ActionLink(
"Update div test",
"SomeAction",
new AjaxOptions { UpdateTargetId = "result" }
) %>
于 2010-05-26T09:01:34.063 回答
0
另一种方法可能是从您的控制器返回一个部分视图并将生成的 html 放入 div 中。
public ActionResult jQueryTagFilter(string filterBy)
{
//Do stuff
return PartialView("TagList", tags);
}
然后在你的html中;
$.post("/Admin/jQueryTagFilter", { filterBy: filter }, function(newUserListHTML) {
$("#divTags").fadeOut(300, function() {
$"#divTags").innerHTML = newUserListHTML;
});
$("#divTags").fadeIn(300);
});
于 2010-05-27T00:39:31.193 回答