MVC Form提交

controller 中

public class Query
{
public string ShopId { get; set; }
public string TaskAccessId { get; set; }

public Query()
{
ShopId = "";
TaskAccessId = "";
}
}
public ActionResult Index(Query query)
{
ViewBag.Message = "修改此模板以快速启动你的 ASP.NET MVC 应用程序。";

return View();
}

 

.cshtml

@{

}
<head>
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function() {
$("#TId").change(function () {
document.forms[0].submit();
});
$("#SId").change(function () {
document.forms[0].submit();
});
});

</script>
</head>
@using (Html.BeginForm())
{
<div >
@Html.DropDownList("TId", MvcApplication2.Controllers.HomeController.TList, "请选择")
</div>
<div >
@Html.DropDownList("SId", MvcApplication2.Controllers.HomeController.SList, "请选择")
</div>
}

posted @ 2016-04-26 21:40  zslm___  阅读(145)  评论(0编辑  收藏  举报