Bootstrap 的 dropdown-menu 控件 的用法
1、<buttonid="Province"type=&孥恶膈茯quot;button"class=""data-toggle="dropdown"aria-expanded="false">省/直辖市/自治区<spanclass=""></span></button><inputtype="hidden"id="HidPro"/><ulclass="dropdown-menu"id="Province"role="menu"aria-labelledby="Province"><li><ahref="#"onclick="Student.GetDropDown(this,1)"code="请选择">请选择</a></li>@foreach(varitemin@ViewBag.GetProvince){<li><ahref="#"onclick="Student.GetDropDown(this,1)"code="@item.StudentID">@item.StudentName</a></li>}</ul>
2、 $.ajax({url:"/CSMP/GetCity&孥恶膈茯quot;,type:"POST",data:撑俯擂摔{"Province":Province},success:function(result){vardata=eval(result);//得到市的实体类,实体类已定通过Json格式转一下,JS中通过evalfor(vari=0;i<data.length;i++){varhtml="";html="<li><acode='"+data[i].StudentID+"'>"+data[i].StudentName+"</a></li>";//定义a标签给a标签定义属性Code,赋值$("#City").append(html);//给li追加a标签$("#Citylia").attr("onclick","Student.GetDropDown(this,2)");//给a标签添加onclick事件}}});
3、通过AJAX请求方法,动态的将省市区赋值到控件上