C#+Ajax CascadingDropDown 实现三级联动 报错 Method error 12030
UI:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CityService.aspx.cs" Inherits="Ajax.page.CityService" EnableEventValidation = "false"%><%@ Register Assembly = "AjaxControlToolkit" Namespace = "AjaxControlToolkit" TagPrefix = "ajaxToolkit"%>
<!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>Ajax实现无刷新三联动下拉框</title>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="sm" runat="server"></asp:scriptmanager>
请选择您所在的城市:
<asp:DropDownList ID="ddlCountry" runat="server"></asp:DropDownList>
<asp:DropDownList ID="ddlProvince" runat="server"></asp:DropDownList>
<asp:DropDownList ID="ddlCity" runat="server"></asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="ccdCountry" TargetControlID="ddlCountry" Category="Country"
PromptText="请选择国家" LoadingText="国家加载中..." ServicePath="CityService.asmx" ServiceMethod="GetCountries"
runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccdProvince" TargetControlID="ddlProvince" Category="Province"
PromptText="请选择省份" LoadingText="省份加载中..." ServicePath="CityService.asmx" ServiceMethod="GetProvincesForCountry"
ParentControlID="ddlCountry" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccdCity" TargetControlID="ddlCity" Category="City"
PromptText="请选择城市" LoadingText="城市加载中..." ServicePath="CityService.asmx" ServiceMethod="GetCitiesForProvince"
ParentControlID="ddlProvince" runat="server" />
</form>
</body>
</html>
service代码:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Collections.Specialized;
using AjaxControlToolkit;
[WebService(Namespace = "http://www.dflying.net/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CityService : System.Web.Services.WebService
{
[WebMethod]
public CascadingDropDownNameValue[] GetCountries(string knownCategoryValues, string category)
{
List<CascadingDropDownNameValue> countryList = new List<CascadingDropDownNameValue>();
// 在真实程序中一般从数据库中读取,这里仅仅是模拟
countryList.Add(new CascadingDropDownNameValue("中国", "china"));
countryList.Add(new CascadingDropDownNameValue("其他", "other"));
return countryList.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] GetProvincesForCountry(string knownCategoryValues, string category)
{
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
// 只模拟提供中国的省份
if (kv["Country"] != "china")
return null;
List<CascadingDropDownNameValue> provinceList = new List<CascadingDropDownNameValue>();
provinceList.Add(new CascadingDropDownNameValue("辽宁", "liaoning"));
provinceList.Add(new CascadingDropDownNameValue("上海", "shanghai"));
provinceList.Add(new CascadingDropDownNameValue("北京", "beijing"));
return provinceList.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] GetCitiesForProvince(string knownCategoryValues, string category)
{
StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
// 只模拟提供辽宁省内的城市
if (kv["Province"] != "liaoning")
return null;
List<CascadingDropDownNameValue> cityList = new List<CascadingDropDownNameValue>();
cityList.Add(new CascadingDropDownNameValue("沈阳", "shenyang"));
cityList.Add(new CascadingDropDownNameValue("大连", "dalian"));
return cityList.ToArray();
}
}
菜鸟学习,大侠们谁知道错在哪儿啊?
--------------------编程问答-------------------- --------------------编程问答-------------------- 少了ParentControlID="ddl_Role" --------------------编程问答-------------------- 那里少了ParentControlID="ddl_Role"
补充:.NET技术 , Web Services