错误500 - CascadingDropDown AJAX Extender工具包控件

时间:2010-08-19 16:15:17

标签: asp.net-ajax .net-2.0 cascadingdropdown

我正在尝试使用CascadingDropDown填充3个下拉列表。 DDL分别显示汽车的品牌,型号和颜色。数据驻留在.xml文件中。

最后一个DDL有AutoPostBack = true,我试图在一个标签控件中显示下拉列表中的值。

我从网络服务中提取数据以填充DDL。编译时我没有收到任何错误但是当我运行代码时它显示错误500.我不知道我哪里出错。我正在关注'我如何'的教程视频 -

http://www.asp.net/ajax/videos/how-do-i-use-the-aspnet-ajax-cascadingdropdown-control-extender

我正在使用C#和.Net framework 2.0。

我的网络服务看起来像这样 -

[WebService(Namespace =“http://tempuri.org/”)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [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文件 -

                                                                                                   

                                                                                               

                                                                                                 

我不确定我哪里出错了。你能帮我吗?

1 个答案:

答案 0 :(得分:0)

Firebug对于调试Web服务调用非常有用。

  1. 安装适用于Firefox的Firebug插件
  2. 在Firefox中打开测试网页
  3. 打开Firebug,然后打开Net选项卡并单击XHR
  4. 再次尝试下拉并查找XHR响应中的错误