我试图使用CascadingDropDown填充3个下拉列表。DDLs分别显示汽车的制造、型号和颜色。数据驻留在.xml文件中。
最后一个DDL有AutoPostBack = true,我试图在一个label控件中显示下拉列表中的值。
我从webservice中提取数据来填充DDL。编译时没有收到任何错误,但是当我运行代码时,它会显示错误500。我不知道我哪里出了问题。我正在听“我该怎么做”的教程视频-
http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-cascadingdropdown-control-extender
我正在使用C#和.Net框架2.0。
我的网络服务看起来是这样的-
Http://tempuri.org/](http://tempuri.org/)“)WebService(命名空间=”][ System.Web.Script.Services.ScriptService()公共类CarsService : System.Web.Services.WebService {
public XmlDataDocument _document;
//public object _lock = new Object();
public CarsService () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
public XmlDocument Document
{
get
{
if (_document==null)
{
_document = new XmlDataDocument();
_document.Load(HttpContext.Current.Server.MapPath("~/App_Data/CarsService.xml"));
}
//Document = _document;
return _document;
}
}
public string[] Hierarchy
{
get
{
string[] hierarchy = {"make","model"};
return hierarchy;
}
}
[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knowncategoryvalues, string category)
{
StringDictionary knownCategoryValuesDictionary = new StringDictionary();
knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knowncategoryvalues);
return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category);
}}
网页看起来是这样的-
Untitled Page <br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" Width="147px">
</asp:DropDownList>
<br />
<asp:DropDownList ID="DropDownList2" runat="server" Width="147px">
</asp:DropDownList>
<br />
<asp:DropDownList ID="DropDownList3" runat="server" Width="147px"
AutoPostBack="True">
</asp:DropDownList>
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="64px" Width="191px"></asp:TextBox>
<br />
<br />
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"
Category="make" PromptText="Please enter dish name"
ServiceMethod="GetDropDownContents" TargetControlID="DropDownList1"
ServicePath="CarsService.asmx">
</ajaxToolkit:CascadingDropDown>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server"
Category="model" LoadingText="[Loading price...]"
ParentControlID="DropDownList1" PromptText="Please select price"
ServiceMethod="GetDropDownContents" TargetControlID="DropDownList2">
</ajaxToolkit:CascadingDropDown>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server"
Category="color" LoadingText="[Loading Description...]"
ParentControlID="DropDownList2" PromptText="Select Description"
ServiceMethod="GetDropDownContents" TargetControlID="DropDownList3">
</ajaxToolkit:CascadingDropDown>
<br />
<br />
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</form>还在这里附加xml文件-
我不知道我哪里出了问题。你能帮帮我吗?
发布于 2010-08-19 16:57:54
火虫对于调试web服务调用是非常宝贵的。
https://stackoverflow.com/questions/3523817
复制相似问题