0
我想要做的是將參數傳遞給用戶控件視圖,該視圖將更新div標籤並根據隱藏的用戶控件呈現新數據。我知道如何使用Ajax.Form()Helper方法更新div標籤,但傳遞參數和更新部分控件已經超出了我的想象。我從來沒有使用過jQuery,並且查找了一些關於如何在mvc中實現它的教程,但是我已經遇到了太多的問題,需要一些幫助來找出解決方案。我目前擁有的是這個,需要擴展它來更新用戶控制視圖。jQuery + MVC用戶控件
ASPX文件
<form id="formParams">
<input name="textSearch1" type="text" />
<input name="textSearch2" type="text" />
<input name="btnTest" type="submit" onclick="$get('recordsForm').onsubmit()" value="Click Me" />
</form>
<% using (Ajax.Form(
"Records",
"Search",
null,
new AjaxOptions
{
UpdateTargetId = "records",
OnSuccess = @"function(sender, args){}",
HttpMethod = "GET"
},
new { @id = "recordsForm" }))
{
}
%>
<div id="records">
<img src="<%= Url.Content("~/Content/Images/load.gif") %>" alt="loading..." />
</div>
ACSX文件
<%= ViewData["searchText1"].ToString()%> is the search you entered.
控制器CS文件
public ActionResult Records(string searchText1, string searchText2)
{
ViewData["searchText2"] = searchText2 + " Stop sucking at jQuery Ayo";
ViewData["searchText1"] = searchText1;
return View("Records");
}