Monday, March 26, 2012

CascadingDropDowns Not Enabling

I'm just trying to get simple cascading drop down functionalityworking, and I'm having some issues with the second drop down gettingenabled once a selection has been made in the first drop down. I candebug and step through correctly, and everything seems like it shouldbe working, it's just that the control is never enabled.

I've checked this thread (http://forums.asp.net/thread/1278728.aspx), because it seemed similiar, and I've already set enabledEventValidation to false for the page. What am I missing?

Here what I've got:

<asp:DropDownList ID="dropdownlist" runat="server" />
<asp:DropDownList ID="dropdownlist1" runat="server" /
<atlasToolkit:CascadingDropDown ID="CascadingDropDowns" runat="server">
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="dropdownlist" Category="Make" PromptText="Pleaseselect a value" ServicePath="dropdown.asmx" ServiceMethod="GetValues"/>
<atlasToolkit:CascadingDropDownPropertiesTargetControlID="dropdownlist1" ParentControlID="dropdownlist"Category="Model" PromptText="Please select a make" ServicePath="dropdown.asmx" ServiceMethod="GetValues" />
</atlasToolkit:CascadingDropDown
And then, my Web Service:

<%@dotnet.itags.org. WebService Language="VB" Class="dropdown" %
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://k299/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class dropdown
Inherits System.Web.Services.WebService

Public Function dropdown()
Return Nothing
End Function

<WebMethod()> _
Public Function GetValues(ByVal knownCategoryValues As String, ByValcategory As String) As AtlasControlToolkit.CascadingDropDownNameValue()
Dim cddvArray(1) As AtlasControlToolkit.CascadingDropDownNameValue
Dim strDisplay As String = ""
If category = "Make" Then
strDisplay = "Michigan"
Else
strDisplay = "Missouri"
End If
Dim cddv1 As New AtlasControlToolkit.CascadingDropDownNameValue(strDisplay, "MO")
cddvArray(0) = cddv1
Return cddvArray
End Function

End Class

You're creating a 2-element array and filling in only one of the two elements, leaving the other empty. Change the first line of GetValues to the following and your sample works fine for me:

Dim cddvArray(0) As AtlasControlToolkit.CascadingDropDownNameValue


And to think, I was pulling my hair out on something that simple. I knew I should have gotten more sleep :)

Thanks!

No comments:

Post a Comment