📄 areaselector.ascx
字号:
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="AreaSelector.ascx.cs" Inherits="DataSaver.SDE2HManager.Common.AreaSelector" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<xml id="AllCities" runat="server" EnableViewState=False></xml>
<xml id="AllSection" runat="server" EnableViewState=False></xml>
<asp:DropDownList id="Province" runat="server"></asp:DropDownList>
<asp:DropDownList id="City" runat="server"></asp:DropDownList>
<asp:DropDownList id="Section" runat="server" AutoPostBack="True"></asp:DropDownList>
<script language=javascript for=<%=Province.ClientID%> event=onchange>
Province_OnChange();
</script>
<script language=javascript for=<%=City.ClientID%> event=onchange>
City_OnChange();
</script>
<script language=javascript>
function Province_OnChange(SelectedSection)
{
if(SelectedSection==null)
SelectedSection="******";
var Province=window.document.all["<%=Province.ClientID%>"];
var City=window.document.all["<%=City.ClientID%>"];
var AllCities=window.document.all["<%=AllCities.ClientID%>"];
while(City.options.length)
City.remove(0);
var Prefix=Province.value.substr(0,2);
var SelectedCity=SelectedSection.substr(0,4)+"00"
var XMLDocument=new ActiveXObject("MSXML2.DOMDocument");
XMLDocument.loadXML(AllCities.innerHTML);
var XMLNodes=XMLDocument.selectNodes("NewDataSet/Area");
for(var Item=XMLNodes.nextNode();Item;Item=XMLNodes.nextNode())
{
var CityCode=Item.selectSingleNode("sz_code").nodeTypedValue;
if(CityCode.substr(0,2)==Prefix)
{
var Option=window.document.createElement("option");
Option.text=Item.selectSingleNode("name").nodeTypedValue;
Option.value=CityCode;
City.options.add(Option)
if(Option.value==SelectedCity)
City.selectedIndex=City.options.length-1;
}
}
City_OnChange(SelectedSection);
}
function City_OnChange(SelectedSection)
{
var Province=window.document.all["<%=Province.ClientID%>"];
var City=window.document.all["<%=City.ClientID%>"];
var Section=window.document.all["<%=Section.ClientID%>"];
var AllSection=window.document.all["<%=AllSection.ClientID%>"];
while(Section.options.length)
Section.remove(0);
var Prefix=City.value.substr(0,4);
if(Prefix=="")
Prefix=Province.value.substr(0,2)+"01";
var XMLDocument=new ActiveXObject("MSXML2.DOMDocument");
XMLDocument.loadXML(AllSection.innerHTML);
var XMLNodes=XMLDocument.selectNodes("NewDataSet/Area");
for(var Item=XMLNodes.nextNode();Item;Item=XMLNodes.nextNode())
{
var SectionCode=Item.selectSingleNode("sz_code").nodeTypedValue;
if(SectionCode.substr(0,4)==Prefix)
{
var Option=window.document.createElement("option");
Option.text=Item.selectSingleNode("name").nodeTypedValue;
Option.value=SectionCode;
Section.options.add(Option);
if(Option.value==SelectedSection)
Section.selectedIndex=Section.options.length-1;
}
}
if(City.options.length)
City.style.display="";
else City.style.display="none";
if(Section.options.length)
Section.style.display="";
else Section.style.display="none";
}
Province_OnChange("<%=this.SelectedArea.AreaCode%>");
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -