AspnetMvc 리셋 없음
3317 단어 asp
/// <summary> /// action json /// </summary> /// <param name="p"> </param> /// <returns></returns> public ActionResult GetCityList(string p) { ; IList<City> cityModelList =// var pList = new SelectList(cityModelList, "CityId", "CityName"); return Json(pList, JsonRequestBehavior.AllowGet); } // public void BindProvince(string defaultText = " ", string defaultValue = "") { var dt =// IList<SelectListItem> items = new List<SelectListItem>(); items.Add(new SelectListItem { Text = defaultText, Value = "", Selected = true }); foreach (var dr in dt) { items.Add(new SelectListItem { Text = dr.ProvinceName, Value = dr.ProvinceCode }); } this.controller.ViewData["Province"] = items; this.controller.ViewData["ddlProvince"] = defaultValue ?? string.Empty; } // public void BindCity(string provinceId, string defaultText = " ", string defaultValue = "") { IList<SelectListItem> items = new List<SelectListItem>(); if (provinceId == string.Empty) { items.Add(new SelectListItem { Text = defaultText, Value = defaultValue }); } else { var dt = // foreach (var dr in dt) { items.Add(new SelectListItem { Text = dr.CityName, Value = dr.CityId }); } } this.controller.ViewData["City"] = items; this.controller.ViewData["ddlCity"] = defaultValue ?? string.Empty; }
2、View
<script src="@Url.Content("~/Scripts/provinceCity.js")" type="text/javascript"></script>
<div class="editor-label">
</div>
<div>
@Html.DropDownList("ddlProvince", ViewData["Province"] as IEnumerable<SelectListItem>)
@Html.DropDownList("ddlCity", ViewData["City"] as IEnumerable<SelectListItem>)
@Html.ValidationMessageFor(model => model.CityId)
</div>
// js , url
@Html.Hidden("GetCityList", Url.Action("GetCityList", "Enterprise"))
3、Js
$(document).ready(function () { $("#ddlProvince").change(function () { getCity($(this).val()); });function getcity(provinveCode) {$("#ddlCity").html(");//$.ajax({type:"GET",url: $("#GetCityList").val(),data:"p="+ provinveCode +"&date="+ new Date(),dataType:"json", success: function (json) { if (json.length > 0) { for (var i = 0; i < json.length; i++) { $("#ddlCity").append("");} else {$("#ddlCity"). append(""을 선택하십시오). } }, error: function (data) { alert(data); } }); }});
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Shadows: Spooktober in Answer Set ProgrammingASP can be viewed as an extension of Prolog. Pure Prolog rules are based on definite clauses, that is Horn clauses which...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.