0

CascadingDropDown を使用して 3 つのドロップダウン リストを作成しようとしています。DDL は、車のメーカー、モデル、色をそれぞれ示します。データは .xml ファイルにあります。

最後の DDL には AutoPostBack = true があり、ドロップダウンの値を 1 つのラベル コントロールに表示しようとしています。

Web サービスからデータをプルして、DDL を設定しています。コンパイル中にエラーは発生しませんが、コードを実行するとエラー 500 が表示されます。どこが間違っているのかわかりません。「How Do I」のチュートリアルビデオに従っています -

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.ウェブサービス {

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);

}

}

そして、Webページは次のようになります -

タイトルのないページ

    <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ファイルを添付 -

どこが間違っているのかわかりません。手伝ってくれませんか ?

4

1 に答える 1

0

Firebugは、Web サービス呼び出しのデバッグに非常に役立ちます。

  1. Firefox 用の Firebug プラグインをインストールする
  2. Firefox でテスト Web ページを開きます
  3. Firebug を開き、[Net] タブを開き、[XHR] をクリックします。
  4. ドロップダウンをもう一度試して、XHR 応答でエラーを探します
于 2010-08-19T16:57:54.690 に答える