Monday, March 26, 2012

CascadingDropDowns in VB

I'm trying to convert the CascadingDropDown list sample to VB and I'm running into a problem. When I view the page, there are no errors but the dropdown lists don't populate. It doesn't seem like the webservice is being run. The reason I say this is beacuse if I change the "ServicePath" property on the aspx page to point to a nonexistant file, I get the exact same results...No error and no data in the lists. But I figure that if the ServicePath that Im pointing at doesn't exist, I should be getting an error. Here is my code for the .vb service and the .aspx code. What am I missing?

Inherits System.Web.Services.WebServicePrivate ReadOnly _document asNew XmlDocument()Private ReadOnly _hierarchy() asString Public Sub CarsService()'Read XML data from disk _document.Load(Server.MapPath("~/App_Data/CarsService.xml")) _hierarchy(0) ="Make" _hierarchy(1) ="Model"End Sub <WebMethod()> _Public Function GetDropDownContents(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As AtlasControlToolkit.CascadingDropDownNameValue()Dim knownCategoryValuesDictionary asNew StringDictionary knownCategoryValuesDictionary = AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Return AtlasControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(_document, _hierarchy, knownCategoryValuesDictionary, category)End Function
<atlas:ScriptManager id="ScriptManager1" EnablePartialRendering="true" runat="server"></atlas:ScriptManager> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"><contenttemplate><table><tr> <td>Make</td> <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td></tr><tr> <td>Model</td> <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td></tr><tr> <td>Color</td> <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" /></td></tr></table><br /><asp:Button ID="Button1" runat="server" Text="I want this car" OnClick="Button1_Click" /><br /><br /><asp:Label ID="Label1" runat="server" Text="[No response provided yet]"></asp:Label></contenttemplate></atlas:UpdatePanel><atlasToolkit:CascadingDropDown id="CascadingDropDown1" runat="server"><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList1" Category="Make"PromptText="Please select a make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" /><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList2" Category="Model"PromptText="Please select a model" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"ParentControlID="DropDownList1" /><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList3" Category="Color"PromptText="Please select a color" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"ParentControlID="DropDownList2" /></atlasToolkit:CascadingDropDown></form>

Hmmm - the code looks okay to me. Two questions:

1) Does the sample website page for CascadingDropDown work okay?

2) If you put a breakpoint in the web service, can you verify that it does or doesn't work


Make sure that your Web.Config is updated to allow browser access to web services. You can find details at this link:

http://atlas.asp.net/docs/atlas/doc/services/exposing.aspx#enable

If you don't then I think you'll find that your drop-down lists will not be populated!

Hope this helps

No comments:

Post a Comment