CascadingDropDown

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CascadingDropDown.aspx.cs" Inherits="AjaxToolkit.CascadingDropDown" EnableEventValidation="false" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
   <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server">
                </asp:DropDownList>
                <asp:DropDownList ID="DropDownList2" runat="server">
                </asp:DropDownList>
                <asp:DropDownList ID="DropDownList3" runat="server">
                </asp:DropDownList>
                <asp:Label ID="Label1" runat="server"></asp:Label>
                <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server"
                    Category="province" LoadingText="[loading a province]" ServicePath="CityService.asmx"
                    PromptText="please select a province" ServiceMethod="GetDropDownContents"
                    TargetControlID="DropDownList1">
                </cc1:CascadingDropDown>
                <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" Category="city"
                    LoadingText="[loading a city]" ParentControlID="DropDownList1"  ServicePath="CityService.asmx"
                    PromptText="please select a city" ServiceMethod="GetDropDownContents"
                    TargetControlID="DropDownList2">
                </cc1:CascadingDropDown>
                <cc1:CascadingDropDown ID="CascadingDropDown3" runat="server" Category="town"
                    LoadingText="[loading a town]" PromptText="please select a towm"  ParentControlID="DropDownList2"  ServicePath="CityService.asmx"
                    ServiceMethod="GetDropDownContents" TargetControlID="DropDownList3">
                </cc1:CascadingDropDown>
                <asp:Button ID="Button1" runat="server" οnclick="Button1_Click" Text="Button" />
            </ContentTemplate>
        </asp:UpdatePanel>

    </div>
   
    </form>
</body>
</html>

 

 

 ========webservice========

  [System.Web.Script.Services.ScriptService]
    public class CityService : System.Web.Services.WebService
    {
        public System.Xml.XmlDocument _document;
        public object _lock;

        public System.Xml.XmlDocument Document
        {
            get
            {
                _document = new System.Xml.XmlDocument();
                _document.Load(HttpContext.Current.Server.MapPath("~/App_Data/Data.xml"));
                return _document;
            }
        }
        public string[] Hierachy
        {
            get
            {
                string[] _hierachy = new string[]{"province","city","town" };
                return _hierachy;
            }
        }
        [WebMethod]
        public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
        {
            System.Collections.Specialized.StringDictionary knowCategoryValuesDictionary = new System.Collections.Specialized.StringDictionary();
            knowCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document,Hierachy,knowCategoryValuesDictionary,category);
        }
    }

 

 

 

=====XML========

 

<?xml version="1.0" encoding="utf-8" ?>
<country>
  <province name="guangdong" value="guangdong">
    <city name="guangzhou" value="guangzhou">
      <town name="huadu" value="huadu"></town>
      <town name="haizhu"></town>
      <town name="xiguan"></town>
    </city>
    <city name="foshan">
      <town name="chancheng"></town>
      <town name="shunde"></town>
      <town name="nanhai"></town>
    </city>
    <city name="shenzhen">
      <town name="longgang"></town>
      <town name="bantian"></town>
      <town name="luohu"></town>
    </city>
  </province>
</country>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值