我想使用CascadingDropDown填充3個下拉列表。 DDL分別顯示汽車的品牌,型號和顏色。數據駐留在.xml文件中。錯誤500 - CascadingDropDown AJAX Extender工具包控件
最後一個DDL有AutoPostBack = true,我試圖在一個標籤控件中顯示下拉列表中的值。
我從Web服務中提取數據以填充DDL。編譯時我沒有收到任何錯誤,但是當我運行代碼時,它顯示錯誤500.我不確定錯誤的位置。我下面的教程視頻 '我如何' -
http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-cascadingdropdown-control-extender
我使用C#和.NET Framework 2.0。
我Web服務看起來是這樣的 -
[WebService的空間(namespace = 「http://tempuri.org/」) [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService( )] public class 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);
}
}
以及網頁看起來是這樣的 -
無標題頁
<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文件 -
我不知道我要去的地方錯了。你能幫我麼 ?
我試過這樣做。但我不明白它卡在哪裏。 – Pratik 2010-08-19 17:12:54
如果您有customErrors模式關閉(http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx),您應該在XHR響應中看到完整的堆棧跟蹤。 – jrummell 2010-08-19 17:28:02