public static string GetDis(string CityID = "1", string DisID = "1", string NameAttr = "DistrictID") { XmlDocument Xml = new XmlData().DistrictsXml; //string path = HttpContext.Current.Server.MapPath("/Content/xmlData/address/Districts.xml"); //Xml.Load(path); XmlNodeList DisNodeList = Xml.SelectNodes("//District[@PID='" + CityID + "']"); StringBuilder strCity = new StringBuilder(); strCity.Append("<select style='width:31%;float:left;margin-left:10px;' class='form-control' id='dis' name='" + NameAttr + "'>"); foreach (XmlNode node in DisNodeList) { if (node.Attributes["ID"].Value == DisID) { strCity.Append("<option selected='selected' value='" + node.Attributes["ID"].Value + "'>" + node.Attributes["DistrictName"].Value + "</option>"); } else { strCity.Append("<option value='" + node.Attributes["ID"].Value + "'>" + node.Attributes["DistrictName"].Value + "</option>"); } } strCity.Append("</select>"); return(strCity.ToString()); }
public static string GetPro(string ProID = "1", string NameAttr = "ProvinceID") { XmlDocument Xml = new XmlData().ProvincesXml; StringBuilder sb = new StringBuilder(); //string path = HttpContext.Current.Server.MapPath("/Content/xmlData/address/Provinces.xml"); //Xml.Load(path); XmlNodeList ProvinceNodeList = Xml.SelectNodes("//Province"); StringBuilder strCity = new StringBuilder(); sb.Append("<select class='form-control' style='width:31%;float:left;' id='pro' name='" + NameAttr + "' onchange='ProChange(this)'>"); foreach (XmlNode node in ProvinceNodeList) { if (node.Attributes["ID"].Value == ProID) { sb.Append("<option selected='selected' value='" + node.Attributes["ID"].Value + "'>" + node.Attributes["ProvinceName"].Value + "</option>"); } else { sb.Append("<option value='" + node.Attributes["ID"].Value + "'>" + node.Attributes["ProvinceName"].Value + "</option>"); } } sb.Append("</select>"); return(sb.ToString()); }