试着使用ajax结合分部视图做了一个异步刷新,记录一下。
显示数据的视图代码:
<p>
@using (Ajax.BeginForm("SearchIndex", "TestDataDB", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "result"}, new { id = "searchForm" } ))
{
<p>用户名:@Html.TextBox("SearchString")<br />
<input type="submit" value="查询"/></p>
}
</p>
<table id="result">
<tr>
<th>
@Html.DisplayNameFor(model => model.Uid)
</th>
<th>
@Html.DisplayNameFor(model => model.Uname)
</th>
<th>
@Html.DisplayNameFor(model => model.Upwd)
</th>
<th>
@Html.DisplayNameFor(model => model.Udata)
</th>