Hi,
I have a problem with cascading drop down. I tried to reproduce the video tutorial with countries and states instead of cars. I can manage to get the first one to work but the second one give me the [Method error 500]. I don't know where I made a mistake.
I really hope someone can answer me.
FMaheu
************** Web service CountryService.asmx *****Imports System.WebImports System.Web.ServicesImports System.Web.Services.ProtocolsImports System.Xml<WebService(Namespace:="http://tempuri.org/")> _<System.Web.Script.Services.ScriptService()> _Public Class CountryServiceInherits System.Web.Services.WebServiceShared _DocumentAs XmlDocumentShared _lockAs New Object Public ReadOnly Property Document()As XmlDocumentGet If (_DocumentIs Nothing)Then SyncLock _lock _Document =New XmlDocument _Document.Load(HttpContext.Current.Server.MapPath("~/App_Data/Copy of countries.xml"))End SyncLock End If Document = _DocumentExit Property End Get End Property Public ReadOnly Property Hierarchy()As String()Get Dim _HierarchyAs String() = {"country","state"}Return _HierarchyEnd Get End Property <WebMethod()> _Public Function GetDropDownContents(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As AjaxControlToolkit.CascadingDropDownNameValue()Dim knownCategoryValuesDictionaryAs New StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category)End FunctionEnd Class************************ aspx file ********<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title> <script runat="server"> <System.Web.Services.WebMethod()> _ <System.Web.Script.Services.ScriptMethod()> _Public Shared Function GetDropDownContentsPageMethod(ByVal knowCategoryValuesAs String,ByVal categoryAs String)As AjaxControlToolkit.CascadingDropDownNameValue()Return New CountryService().GetDropDownContents(knowCategoryValues, category)End Function </script></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" Width="213px"> </asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server" Width="212px"> </asp:DropDownList> <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="country" LoadingText="[Loading countries ...]" ServiceMethod="GetDropDownContents" ServicePath="CountryService.asmx" PromptText="Please select a country" TargetControlID="DropDownList1"> </cc1:CascadingDropDown> <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" ParentControlID="DropDownList1" Category="state" LoadingText="[Loading states ...]" ServiceMethod="GetDropDownContentsPageMethod" PromptText="Please select a state" TargetControlID="DropDownList2"> </cc1:CascadingDropDown> </ContentTemplate> </asp:UpdatePanel> </form></body></html>Nevermind I kinda got it to work somehow ...
Hi FMaheu,
I am having same problem as you mentioned. First dropdown works but second dropdown is giving me error "Method Error 500". Would you please let me know what change that you made on your code to fix that error.
Thank You,
Nepalaya
Hi nepalaya,
Sorry for the delay, I'm very busy these days. So instead of using a page method I used the method in my countryservice.asmx. Something seemed to be wrong with my page method and since I could just use the same method as the first cascading drop down ...
I have also read in other threads that the control could only support a limited number of objects. That could be modified in the web.config file.
I hope this helps
FMaheu
P.S. I posted my ASP.NET Code in case in would help you understand better.
1 <cc1:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="country" LoadingText="[Chargement des pays ...]"2 ServiceMethod="GetDropDownContents" ServicePath="CountryService.asmx" PromptText="Sélectionner un pays" TargetControlID="DropDownList1">3 </cc1:CascadingDropDown>4 <cc1:CascadingDropDown ID="CascadingDropDown2" runat="server" ParentControlID="DropDownList1" Category="state" LoadingText="[Chargement des états/porvinces ...]"5 ServiceMethod="GetDropDownContents" PromptText="Sélectionner un état/province" TargetControlID="DropDownList2" ServicePath="CountryService.asmx">6 </cc1:CascadingDropDown>7
Thank You very much.
Yes it works.
Thanks,
Mani
I have my code identical to yours and I am getting a method error 12030. Any ideas?
From my search, that error is given to you when your aspx page cannot reach the web service. Is your service external to your web project? If so try copy it inside your web project. It seems calling an external web service doesn't work very well with CascadingDropDown.
Hope this helps a little
my web service (.asmx file) is in my web project. It is weird, sometimes I get method error 500 errors and sometimes I get method error 12030 errors. There isn't a pattern that I can find.
Most likely the web service isn't defined or hooked up properly. The ASP.NET AJAX infrastructure is pretty unforgiving here, so make sure everything is as it should be.
No comments:
Post a Comment