我有一个Ajax助手类,它调用控制器,控制器又使用模型数据返回PartialViewResult,PartialViewResult
呈现IEnumerable
。我想从PartialViewResult
返回的模型中获取一个ID,我不知道该怎么做,我甚至使用了TempData
但它没有用,所以AjaxLink
有{{1}获取数据然后数据是html格式的方法所以我需要一些从模型中获取ID并将其分配给OnSucesss
的东西(请查看父视图的最后一条语句)
控制器
Actionlink
ParentView
public ActionResult GetContacts(string q, int limit = 5, int p = 1, int per_page = 5)
{
return PartialView("DateRange2_Partial", Model);
}
PartialView
<div class="col-xs-6" id="DepartmentDetails">
@Html.Partial("DateRange2_Partial",Model)
</div>
@Ajax.ActionLink("click me",
"GetContacts",
"Home",
new AjaxOptions
{
UpdateTargetId = "DepartmentDetails",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
OnSuccess = "OnAjaxRequestSuccess"
}
)
<script type="text/javascript">
function OnAjaxRequestSuccess(data) {
// Get value from data and pass it to the Action link?
}
<script/>
@Html.ActionLink("Redirect", "Action", new { SingleDatePicker = ***Assign value here from Ajax action link***})