2010-08-19 5 views
0

J'essaie de remplir 3 listes déroulantes en utilisant CascadingDropDown. DDL montre la marque, le modèle et la couleur d'une voiture respectivement. Les données résident dans un fichier .xml.Erreur 500 - Contrôle de la boîte à outils AJAX Extender CascadingDropDown

Le dernier DDL est d'avoir AutoPostBack = true et j'essaye d'afficher les valeurs de la liste déroulante dans un contrôle d'étiquette. Je tire des données d'un webservice pour peupler DDLs. Je ne reçois aucune erreur lors de la compilation, mais quand je cours le code il montre Erreur 500. Je ne suis pas sûr où je vais mal. Je suis la vidéo tutoriel de 'Comment puis-je' -

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

J'utilise C# et .Net Framework 2.0.

Mon Service Web ressemble à ceci -

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

} 

}

Et page Web ressemble à ceci -

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> 

Fixation fichier xml aussi ici -

Je ne sais pas où je me trompe. Pouvez-vous m'aider s'il vous plaît ?

Répondre

0

Firebug est une valeur inestimable pour le débogage des appels de service Web.

  1. Installez le plugin Firebug pour Firefox
  2. Ouvrez votre page Web test dans Firefox
  3. Ouvrir Firebug, puis ouvrez l'onglet Net et cliquez sur XHR
  4. Tentez votre chute à nouveau et chercher l'erreur dans la réponse XHR
+0

J'ai essayé de le faire. Mais je ne comprends pas où ça se coince. – Pratik

+0

Si le mode customErrors est désactivé (http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx), vous devez voir la trace de pile complète dans la réponse XHR. – jrummell

Questions connexes