asp.net中如何实现dropdownlist的onselectedindexchanged的类似方法
asp.net中如何实现dropdownlist的onselectedindexchanged的类似方法
用MVC做一个查询系统,根据公司名称查询公司的员工情况
用dropdownlist绑定公司
<%=Html.DropDownList("list", new List<SelectListItem>
{
(new SelectListItem() {Text = "微软", Value = "66"}),
(new SelectListItem() {Text = "IBM", Value = "67"})
})%>
想在 DropDownList中选择不同公司的时候没,触发homecontroller 中的index函数,如何实现这一功能,谢谢
------解决方案--------------------
保持选项
<%=Html.DropDownList("list", new List<SelectListItem>
{
(new SelectListItem() {Text = "微软", Value = "66",Selected=Request.QueryString["s"]=="66"}),
(new SelectListItem() {Text = "IBM", Value = "67",Selected=Request.QueryString["s"]=="67"})
}, new { onchange = "window.location.href='" + Request.FilePath + "?s=' + this.value;" })%>
------解决方案--------------------
or
<%
String s = Request.QueryString["s"];
if (s == null) s = "";
%>
<%=Html.DropDownList("list", new List<SelectListItem>
{
(new SelectListItem() {Text = "微软", Value = "66",Selected=s=="66"}),
(new SelectListItem() {Text = "IBM", Value = "67",Selected=s=="67"})
}, new { onchange = "window.location.href='" + Request.FilePath + "?s=' + this.value;" })%>