드롭 다운리스트에 자동 포스트 백을 수행하고 싶습니다. 보기에 내 양식 :리다이렉트 액션 ASP.NET MVC3에서 url 변경 링크
@using (Html.BeginForm("Index", "Model", FormMethod.Post))
{
@(Html.Telerik().DropDownList()
.Name("ddlBrands")
.BindTo((IEnumerable<SelectListItem>)ViewData["brands"])
.ClientEvents(events => events
.OnChange("onDropDownListChange")
)
)
<input type="submit" value="OK" />
<table style="margin:15px; margin-left:0px;">
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.FullModel)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ModelID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ModelID })
</td>
</tr>
}
</table>
}
및 자바 스크립트 :
<script type="text/javascript">
function onDropDownListChange(e) {
SimpleAjaxRequest('/Model/Index', e.value);
}
function SimpleAjaxRequest(url, requestData) {
return $.ajax(
{
type: 'POST',
url: url,
async: true,
data: { ddlBrands: requestData },
dataType: "json",
traditional: true
});
}
</script>
나는 서버에 인덱스보기에서 아약스를 통해 포스트 데이터를 전송 및 조작 데이터 후 나는 내 양식에 업데이트 데이터가 필요합니다. 내가 어떻게 할 수 있니? 나는 GET 동작
public ActionResult Index(int? ddlBrands)
{
SetBrandItems();
List<Model> m = dm.GetModelsByBrandId(ddlBrands).ToList();
return View(m);
}
를 호출 한 후 조치를
[HttpPost]
public ActionResult Index(string ddlBrands)
{
SetBrandItems();
return RedirectToAction("Index", "Model", new {ddlBrands = ddlBrands});
}
을 게시하려면 리디렉션하려고 해요하지만 내 페이지가 새로 고쳐지지 및 URL이 변경되지 및 데이터 업데이트되지 ... 아무도 나를 도울 수 있습니까?
메신저, 당신은 페이지를 새로 고침 싶지 않아? 또는 페이지를 새로 고치시겠습니까? – Rafay
메신저 내 페이지를 새로 고침하고 싶습니다. 하지만 다른 변종을 알고 내 양식에 날짜를 업데이 트하는 경우, pls 도움 – user571874
당신의 GET 지수 방법은 어떻게 보이나요 – Rafay