Showing posts with label cascadingdropdowns. Show all posts
Showing posts with label cascadingdropdowns. Show all posts

Monday, March 26, 2012

cascadingdropdowns when only one listitem

I am happily using cascading dropdowns for a three-level stack. In some cases, there is only one item in the generated list apart from the select prompt. Common sense and good design suggests that the one item should be auto-selected but this has not been implemented in the Toolkit.

I tried to implement it by setting the selected attribute (third parameter) to 'true' in the Web service. This worked for the displayed ddl, but the underlying value was not set . Hence the next level in the dropdown failed because no value was supplied.

Is this a bug or am I doing something wrong?

The relevant line in the VB Web Service (PageMethod) is:

values.Add(

New CascadingDropDownNameValue(sCompany, sCompanyId,True))

If I do not use the third parameter, I get the standard result with my Prompt showing in the ddl, and everything working when I actually select the one item.

This sounds like a bug. Could you whip up a quick sample page demonstrating the problem and file the issue at CodePlex?

http://www.codeplex.com/WorkItem/List.aspx?ProjectName=AtlasControlToolkit

Thanks!

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!

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

CascadingDropDowns from bad to worse...

I was getting a [Method Error 500] on a DropDown and was combing through the posts trying to find a solution. I stripped my code down to two simple DropDowns with CascadingDropDown controls attached to them. I was able to get the top level control to populate correctly but was still getting the Eror 500 on my child DropDown. One of the posts I saw suggested making my Web Service methods Shared (I'm using VB). I tried that and now my original DropDown stopped populating at. The Web Service code isn't being reached at all. I tried removing the Shared designation from my methods but the problem has not gone away. I have cleared my IE cache and completely recreated the project. Still, I can't get a single DropDown to populate usnig a Cascading DropDown and a WebService.Here's my aspx markup:

Here's the code in my WebService: _ _ _ _Public Class Locations Inherits System.Web.Services.WebService Private Shared ConnString As String = ConfigurationManager.ConnectionStrings("Inventory").ToString() Private Shared SqlCN As New SqlConnection(ConnString) _ _ Public Shared Function GetLocations() As CascadingDropDownNameValue() Try Dim Ds As DataSet = GetLocationDs() Ds.Tables(0).DefaultView.Sort = "Text ASC" Dim Values As New List(Of CascadingDropDownNameValue) For Each Dr As DataRow In Ds.Tables(0).DefaultView.Table.Rows Values.Add(New CascadingDropDownNameValue(Dr("Text").ToString(), Dr("Value").ToString())) Next Return Values.ToArray() Catch ex As Exception Dim newEx As Exception = ex Return Nothing End Try End Function Private Shared Function GetLocationDs() As DataSet Try Dim SqlCmd As SqlCommand = SqlCN.CreateCommand() Dim PTextColumn As New SqlParameter() Dim PValueColumn As New SqlParameter() Dim PTableName As New SqlParameter() Dim SqlDA As SqlDataAdapter = New SqlDataAdapter() Dim DropDownDS As DataSet = New DataSet() Dim I As Integer = 0 With PTextColumn .DbType = DbType.String .ParameterName = "@dotnet.itags.org.TextColumn" .Value = "Location" End With With PValueColumn .DbType = DbType.String .ParameterName = "@dotnet.itags.org.ValueColumn" .Value = "Location" End With With PTableName .DbType = DbType.String .ParameterName = "@dotnet.itags.org.TableName" .Value = "HE_Locations" End With With SqlCmd .CommandType = CommandType.StoredProcedure .CommandText = "usp_GetDropDownValues" .Parameters.Add(PTextColumn) .Parameters.Add(PValueColumn) .Parameters.Add(PTableName) End With SqlDA.SelectCommand = SqlCmd If SqlCN.State <> ConnectionState.Closed Then SqlCN.Close() End If SqlCN.Open() SqlDA.Fill(DropDownDS, "Values") Return DropDownDS Catch ex As Exception Throw New DataException("GetDropDownValues failed.", ex) Return Nothing Finally SqlCN.Close() End Try End FunctionEnd ClassIf anyone has any ideas, I would sure like to hear them. I'm about ready to pull out my AJAX manual and roll my own. I have lost a whole day on this. Even if I get my original DropDown working I still have the ubiquitous Method Error 500 to deal with.Btw, the code in my Catch block was simply a place to put a breakpoint for debugging so I could read exception mesage if there was one. There wasn't.Thanks!

Well, that didn't come out very well, did it?

Actually, nevermind. For some reason, after using the I.E. Devloper Toolbar, scripting in I.E. was disabled. I also figured out my Method Error 500 problem. I realize now that the parameters in the method signature have to match the example exactly - even the case. I assumed that wouldn't matter since I'm using VB.

Thanks.

CascadingDropDowns cant fire OnSelectedIndexChanged client events?

Greetings, all...

I've got a page with a CascadingDropDown setup. On the third dropdown, I want to fire an update panel event to fetch data.

For whatever reason, it does not appear that I can get any of the three dropdowns in the cascade to recognize a client-side OnSelectedIndexChanged event - even when added programmatically in the code file.

The event/action are emitted correctly to the control, but it doesn't seem to fire the event.

I've been trying to find the answer in previous posts and Google, but I don't seem to be finding the answers anywhere. I'm hoping there's someone out in forumland that has seen this before and knows how to resolve the issue.

Thanks in advance for the help,

Ric Castagna

Unless I'm mistaken, OnSelectedIndexChanged is a server-side event, not a client-side one.

CascadingDropDownProperties not recognised in AJAX

Hi,

I've been using CascadingDropDowns quite successfully in Atlas but have now hit a problem moving to ASP.NET AJAX.


I get a message saying "Element 'CascadingDropDownProperties' is not a known element. This can occur if there is a compilation error in the web site."

When I compile, I get an error message saying "'AjaxControlToolkit.CascadingDropDown' does not have a public property named 'CascadingDropDownProperties'".

In my VB code, I import the AjaxControlToolkit but I get a message saying "Type 'CascadingDropDownProperies' is not defined" and "'GetTargetProperties' is not a member of 'AjaxControlToolkit.CascadingDropDown'".

It almost seems as though CDD properties have been dropped, but that can't be right - can it?

I guess I must be missing something fundamental. Any ideas? I have pasted by code below and highlighted the offending lines...

-- Search.aspx --
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="true" CodeFile="Search.aspx.vb" MasterPageFile="~/MasterPage.master" Inherits="Search" Title="TiberPass: Property Search Page" %
<%@dotnet.itags.org. Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="AjaxCTK"
%
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<AjaxCTK:CascadingDropDown ID="cdd" runat="server" >
<AjaxCTK:CascadingDropDownProperties
Category="Province"
PromptText="-- Any Province --"
ParentControlID="ddlRegion"
ServiceMethod="GetProvincesForRegion"
ServicePath="ListcountService.asmx"
TargetControlID="ddlProvince" />
<AjaxCTK:CascadingDropDownProperties
Category="Town"
ParentControlID="ddlProvince"
PromptText="-- Any Town --"
ServiceMethod="GetTownsForProvince"
ServicePath="ListcountService.asmx"
TargetControlID="ddlTown" />
<AjaxCTK:CascadingDropDownProperties
TargetControlID="ddlRegion"
Category="Region"
ServicePath="ListcountService.asmx"
ServiceMethod="GetRegions"
PromptText="-- Any Region --" />
</AjaxCTK:CascadingDropDown>
....


-- Search.aspx.vb --
Imports AjaxControlToolkit

Partial Class Search
Inherits SmartSessionPage

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

' Retrieve Atlas Cascading Dropdown settings from session variables
Dim properties AsCascadingDropDownProperties

' Region
properties = cdd.GetTargetProperties(ddlRegion)
If properties IsNot Nothing Then
If RegionID <> Nothing Then
properties.SelectedValue = RegionID
End If
End If

' Province
properties = cdd.GetTargetProperties(ddlProvince)
If properties IsNot Nothing Then
If ProvinceID <> Nothing Then
properties.SelectedValue = ProvinceID
End If
End If

' Town
properties = cdd.GetTargetProperties(ddlTown)
If properties IsNot Nothing Then
If TownID <> Nothing Then
properties.SelectedValue = TownID
End If
End If

End Sub

End Class

-- MasterPage.Master --
<%@dotnet.itags.org. Master Language="VB" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Tiber Pass</title>
<link rel="stylesheet" type="text/css" href="http://links.10026.com/?link=css/main.css"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
<asp:ScriptManager ID="ScriptManager1" runat="server" enablepartialrendering="true">
</asp:ScriptManager>
</div>
</form>
</body>
</html
-- Web.config --
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.Preview.UI" assembly="Microsoft.Web.Preview"/>
<add tagPrefix="asp" namespace="Microsoft.Web.Preview.UI.Controls" assembly="Microsoft.Web.Preview"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="false">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<microsoft.web>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the setProperties and
getProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
</scripting>
</microsoft.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
</handlers>
</system.webServer>
</configuration

Android:

Hi,

I've been using CascadingDropDowns quite successfully in Atlas but have now hit a problem moving to ASP.NET AJAX.


I get a message saying "Element 'CascadingDropDownProperties' is not a known element. This can occur if there is a compilation error in the web site."

When I compile, I get an error message saying "'AjaxControlToolkit.CascadingDropDown' does not have a public property named 'CascadingDropDownProperties'".

In my VB code, I import the AjaxControlToolkit but I get a message saying "Type 'CascadingDropDownProperies' is not defined" and "'GetTargetProperties' is not a member of 'AjaxControlToolkit.CascadingDropDown'".

It almost seems as though CDD properties have been dropped, but that can't be right - can it?

The properties have been moved for the new release of ASP.NET AJAX. There's more information in themigration guide for the toolkitand examples of how the new approach works in thesample page for the cascading dropdown control. I hope this helps!


Ah! That explains it. I thought I must have missed something pretty fundamental. Thanks for that.

I've been attempting to convert my code, but come across a problem when I try to use CascadingDropDownProperties and GetTargetProperties. I guess these don't exist any more but what do I use instead? Sorry if this seems basic, but I'm not very technical and am only using VB.NET reluctantly (I kind of hoped Atlas/Ajax would do it all for me, sigh). The examples are in C#.

I'm trying to set my drop down lists based on saved session variables. It was working OK in Atlas, but now I'm struggling. Any ideas? Here are the main parts of my code with the offending bits highlighted:

-- Search.aspx --
<AjaxCTK:CascadingDropDown
ID="cddProvince"
runat="server"
Category="Province"
PromptText="-- Any Province --"
ParentControlID="ddlRegion"
ServiceMethod="GetProvincesForRegion"
ServicePath="ListcountService.asmx"
TargetControlID="ddlProvince"
LoadingText="Loading Provinces..." />
<AjaxCTK:CascadingDropDown
ID="cddTown"
runat="server"
Category="Town"
ParentControlID="ddlProvince"
PromptText="-- Any Town --"
ServiceMethod="GetTownsForProvince"
ServicePath="ListcountService.asmx"
TargetControlID="ddlTown"
LoadingText="Loading Towns..." />
<AjaxCTK:CascadingDropDown
ID="cddRegion"
runat="server"
TargetControlID="ddlRegion"
Category="Region"
ServicePath="ListcountService.asmx"
ServiceMethod="GetRegions"
PromptText="-- Any Region --"
LoadingText="Loading Regions..." /
-- Search.aspx.vb --
Dim properties AsCascadingDropDownProperties

' Region
properties = cddRegion.GetTargetProperties(ddlRegion)
If properties IsNot Nothing Then
If RegionID <> Nothing Then
properties.SelectedValue = RegionID
properties = RegionID
End If
End If



Android:

Ah! That explains it. I thought I must have missed something pretty fundamental. Thanks for that.

I've been attempting to convert my code, but come across a problem when I try to use CascadingDropDownProperties and GetTargetProperties. I guess these don't exist any more but what do I use instead? Sorry if this seems basic, but I'm not very technical and am only using VB.NET reluctantly (I kind of hoped Atlas/Ajax would do it all for me, sigh). The examples are in C#.

I'm trying to set my drop down lists based on saved session variables. It was working OK in Atlas, but now I'm struggling. Any ideas? Here are the main parts of my code with the offending bits highlighted:


-- Search.aspx.vb --
Dim properties AsCascadingDropDownProperties

' Region
properties = cddRegion.GetTargetProperties(ddlRegion)
If properties IsNot Nothing Then
If RegionID <> Nothing Then
properties.SelectedValue = RegionID
properties = RegionID
End If
End If


I think they changed how you access the individual dropdownlists. You can now directly access them, so if you want to set the selectedValue of the ddlRegion control, do this:

cddRegion.SelectedValue = RegionID

I assume RegionID is stored somewhere in Session. It sounds like you're doing that.

One thing I would watch out for is the order you set the selectedValues for the cascading dropdowns. I haven't used the control yet, but I assume it might have problems if you don't assign a value to the parent dropdownlist, then the one under it, then the one under it, and so on.

Best of luck, let us know how it went!


That's great. It's much easier now.

You're right, I'm storing RegionID, etc. as session variables. The idea is that the drop downs will retain the user selections when they return to this page. I had it working fine before.

Now I have a new problem. For some reason the code I have written in my search page to populate the drop downs is not being executed. I have set up 3 drop downs with 3 associated CDDs. The dropdowns should call service methods like "GetRegions" and "GetProvincesForRegion", etc. within ListCountService.asmx, but it never gets that far. The drop downs come up with a Method Error 500. I've put a breakpoint in GetRegions, but it doesn't get activated. Maybe it's something in my header? Before, I had EnableEventValidation, EnableViewState and AutoEventWireup set to false. Now I just have AutoEventWireup set to true and don't mention the other two.

The code for Search.aspx hasn't changed since my last post and I haven't touched the code in ListCountService.asmx. Besides, no matter how good or bad the code is, it just isn't running!

I really appreciate your help on this.

Andrew


Check out Cranzy's post inthis thread andthis blog post by Shawn Burke. I hope this helps!

Fantastic! That's solved it and it's all working fine now. Thanks very much. I'm pretty sure I wouldn't have spotted that other post or blog entry without a nudge in the right direction.

Thanks again,

Andrew

Wednesday, March 21, 2012

CascadingDropDown returns [Method Error 12031] after upgrade to 1.0 Beta

After upgrading from the July CTP to 1.0 Beta all my CascadingDropDown's have stoped working. I only get [Method error 12031] in return an all of them. I hade the same problem when implementing them the first time but I then found the answer in thread 1393072 and referenced threads. This time however I am not able to find anything that helps me. I have tried to migrate my July CTP projekt to a new empty 1.0 Beta project but it doesn't help. Have anyone else hade the same problem?

I am grateful for any suggestions and tips!!

Have you made sure to decorate your service class with this attribute?

[Microsoft.Web.Script.Services.ScriptService()]
public class MyService : WebService
{
...
}


Thanks allot!

Now i works just fine. One can wonder why that line isn't in the walkthrough for CascadingDropDown!


Thanks a lot for that! That's been bugging me all morning. Although I didn't have [Method Error 12031], I had [Method Error 500], this solution still worked for me. It really should be in the walkthrough
I Agree! This should be added RIGHT AWAY!!!

Hey Guys,

Actually there is some documentation and I'll point you to where I found most of my upgrade info. Garbin's recent post on his blog has three links to some very vital information.

http://aspadvice.com/blogs/garbin/archive/2006/10/20/MS-AJAX-v1.0-Beta-and-Ajax-Control-Toolkit-released_2100_.aspx

The CTP-to-Beta whitepaper is where I found the not for adding the ScriptService attribute.

Hope this helps.


The method error 12030 still appears for me when I use the CTP and the specified attribute.

Regards

Vinit


Did you change the return type of your methods that populate your drop downs to return an array of AjaxControlToolkit.CascadingDropDownNameValue objects?

All web methods for child drop downs must have a signature that conforms to the following:

[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDataForMyChildDropDown(string knownCategoryValues, string category)

You can find this in the CTP-to-Beta whitepaper I believe.


Hiya.

Had the same problem and finally found out why. None of the other things suggested worked. Thanks to Steve Clements for that one... http://geekswithblogs.net/steveclements/archive/2006/10/23/94893.aspx

The web service class either needs

[Microsoft.Web.Script.Services.ScriptService]

or

using Microsoft.Web.Script.Services;

namespace Clm.Web.Services

{

[ScriptService]

publicclassFoo


Your most welcome :)

Steve


Same problem, but using only pagemethods...

What changes do I need to get it working?


Can you post some code?
http://forums.asp.net/thread/1486194.aspx

Hi,

I've run into the same error. However, when I change the line in the webservice.vb file from:

<System.Web.Script.Services.ScriptService ()>'

to:

<Microsoft.Web.Script.Serices.ScriptService ()
I get the error 'Type Microsoft.Web.Script.Serices.ScriptService' is not defined'

The whole "snippet":

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class CarsService
Inherits System.Web.Services.WebService

Shared _DocumentAs XmlDocument
Shared _lockAs New Object

I'd appreciate any suggestions.
Thanks!

CascadingDropDown Out of Stack Space

I am getting an "Out of stack space" javascript error when I put more than 8 CascadingDropDowns in one page.

Here is my page source:

<%@dotnet.itags.org. Page Language="VB" MasterPageFile="~/Boss.master" Title="PlowSelection" %><%@dotnet.itags.org. Import Namespace="System.Collections.Generic" %><script runat="server">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)If Not Me.IsPostBack ThenMe.VehicleSelectionPopUp.Show = TrueEnd IfEnd Sub</script><asp:Content ID="HeaderContent" ContentPlaceHolderID="HeaderContentPlaceHolder" Runat="Server"><h1>PLOW SELECTION</h1><p>Go through the list boxes and select your vehicle specs. Select which plowand plow options you would like.</p></asp:Content><asp:Content ID="MainContent" ContentPlaceHolderID="MainContentPlaceHolder" Runat="Server"><div id="SelectedVehiclePlow"><div id="SelectedVehicle"><nsi:TemplateView ID="SelectedVehicleTemplateView" DataSourceID="SelectedVehicleDataSource" runat="server"><EmptyDataTemplate>No Vehicle Selected</EmptyDataTemplate><ItemTemplate><%# Eval("Year")%></ItemTemplate></nsi:TemplateView></div><div id="SelectedPlow">No Plow Selected</div></div><nsi:PopUp ID="VehicleSelectionPopUp" CloseButtonID="CloseButton" runat="server"><Header><asp:HyperLink ID="CloseButton" NavigateUrl="javascript:void(0);" runat="server" SkinID="PopUpCloseButtonHyperLink" />Vehicle Selection</Header><Content><asp:UpdatePanel ID="VehicleSelectionUpdatePanel" runat="server" UpdateMode="Conditional"><ContentTemplate><asp:DropDownList ID="VehicleYearDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleYearCascadingDropDown" Category="Year"LoadingText="[Loading...]" PromptText="Select a Year" runat="server"ServiceMethod="GetVehicleSelectionData" ServicePath="~/WebServices/Vehicles.asmx"TargetControlID="VehicleYearDropDownList" /><asp:DropDownList ID="VehicleMakeDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleMakeCascadingDropDown" Category="Make"LoadingText="[Loading...]" ParentControlID="VehicleYearDropDownList" PromptText="Select a Make"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleMakeDropDownList" /><asp:DropDownList ID="VehicleModelDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleModelCascadingDropDown" Category="Model"LoadingText="[Loading...]" ParentControlID="VehicleMakeDropDownList" PromptText="Select a Model"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleModelDropDownList" /><asp:DropDownList ID="VehicleDriveTrainDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleDriveTrainCascadingDropDown" Category="DriveTrain"LoadingText="[Loading...]" ParentControlID="VehicleModelDropDownList" PromptText="Select a Drive Train"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleDriveTrainDropDownList" /><asp:DropDownList ID="VehicleCabDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleCabCascadingDropDown" Category="Cab"LoadingText="[Loading...]" ParentControlID="VehicleDriveTrainDropDownList" PromptText="Select a Cab"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleCabDropDownList" /><asp:DropDownList ID="VehicleBedDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleBedCascadingDropDown" Category="Bed"LoadingText="[Loading...]" ParentControlID="VehicleCabDropDownList" PromptText="Select a Bed"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleBedDropDownList" /><asp:DropDownList ID="VehicleFgawrDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleFgawrCascadingDropDown" Category="Fgawr"LoadingText="[Loading...]" ParentControlID="VehicleBedDropDownList" PromptText="Select a FGAWR"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleFgawrDropDownList" /><asp:DropDownList ID="VehicleWheelBaseDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleWheelBaseCascadingDropDown" Category="WheelBase"LoadingText="[Loading...]" ParentControlID="VehicleFgawrDropDownList" PromptText="Select a Wheel Base"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleWheelBaseDropDownList" /><asp:DropDownList ID="VehicleRearWheelDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleRearWheelCascadingDropDown" Category="RearWheel"LoadingText="[Loading...]" ParentControlID="VehicleRearWheelDropDownList" PromptText="Select a Rear Wheel"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleRearWheelDropDownList" /><asp:DropDownList ID="VehicleEngineDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleEngineCascadingDropDown" Category="Engine"LoadingText="[Loading...]" ParentControlID="VehicleEngineDropDownList" PromptText="Select an Engine"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleEngineDropDownList" /><asp:DropDownList ID="VehicleHeadlightsDropDownList" runat="server" /><ajax:CascadingDropDown ID="VehicleHeadlightsCascadingDropDown" Category="Headlights"LoadingText="[Loading...]" ParentControlID="VehicleEngineDropDownList" PromptText="Select Headlights"runat="server" ServiceMethod="GetVehicleSelectionData"ServicePath="~/WebServices/Vehicles.asmx" TargetControlID="VehicleHeadlightsDropDownList" /></ContentTemplate></asp:UpdatePanel></Content></nsi:PopUp><asp:ObjectDataSource ID="SelectedVehicleDataSource" DataObjectTypeName="Nsi.Applications.Boss.Service.Vehicle"runat="server" SelectMethod="GetSelectedVehicle" TypeName="Nsi.Applications.Boss.Service.Controller" /></asp:Content>

Here is my web service source:

<%@dotnet.itags.org. WebService Language="VB"Class="Vehicles" %>Imports System.Collections.GenericImports System.WebImports System.Web.Script.ServicesImports System.Web.ServicesImports System.Web.Services.ProtocolsImports AjaxControlToolkitImports Nsi.Applications.Boss.Service<ScriptService(), WebService(Namespace:="http://service.bossplow.com/"), WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _Public Class Vehicles :Inherits System.Web.Services.WebService<WebMethod()> _Public Function GetVehicleSelectionData(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()Dim knownValuesAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Dim typeAs VehicleSelectionAttributeType =CType(System.Enum.Parse(GetType(VehicleSelectionAttributeType), category), VehicleSelectionAttributeType)Dim keyValuesAs List(Of KeyValuePair(OfString,String)) =NothingkeyValues = Nsi.Applications.Boss.Service.Vehicles.GetVehicleSelectionData(type, knownValues("Year"), knownValues("Make"), knownValues("model"), knownValues("DriveTrain"), knownValues("Cab"), knownValues("Bed"), knownValues("Fgawr"), knownValues("WheelBase"), knownValues("RearWheel"), knownValues("Engine"))Dim nameValuesAs New List(Of CascadingDropDownNameValue)()For Each keyValueAs KeyValuePair(OfString,String)In keyValuesnameValues.Add(New CascadingDropDownNameValue(keyValue.Value, keyValue.Key))NextReturn nameValues.ToArray()End FunctionEnd Class

If i take off the last three CascadingDropDowns on the page, everything works great, but when there is more than 8 drop downs on the page, it gives an "Out of stack space" error. Is there a limit to the amount of CascadingDropDowns that are allowed on one page? The maximum number of entries that each list will have is 30.

Never mind. I found my problem and boy is it a stupid one. In two of the CascadingDropDowns I set the ParentControlID the same as the TargetControlID. I need a dunce cap.

CascadingDropDown Method Error 500 Bug

Hello,

I have been trying out CascadingDropDown for few weeks now. One thing that I specifically noticed is that all Cascadingdropdowns works fine with the webservice. But the problem happens if number of rows returned to CascadingDropDown is more than 906, then I get method error 500.


Is 907 a magic number OR CascadingDropDowns cannot carry more data? I debugged the webservice and the array that it returns looks ok even if has more than 906 records. Just the CascadingDropDown doesn't like if get more than some specific amount/ number of records

Is there any solution or workaround?

------

Here's my webservice method

 <WebMethod()> _ Public Function GetPages(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue() Dim Values As List(Of CascadingDropDownNameValue) = New List(Of CascadingDropDownNameValue) Dim Kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues) Dim Ds As DataSet Ds = DbImageInfo.ExecuteQuery("SELECT Page FROM ImageInfo WHERE County=" & Kv("County") & " AND Type='" & Kv("Docket") & "' AND Book='" & Kv("Book") & "' ORDER BY Page") For Each Dr As DataRow In Ds.Tables(0).Rows Values.Add(New CascadingDropDownNameValue(Dr("Page").ToString, PadVariableLength(Dr("Page").ToString)) Next Return Values.ToArray End Function

-------

And here's my asp.net tags

 <ajaxToolkit:CascadingDropDown ID="CascadingDropDown4" runat="server" TargetControlID="DdlPage" Category="Page" PromptText="Page..." LoadingText="[Busy...]" ServicePath="WebService.asmx" ServiceMethod="GetPages" ParentControlID="DdlBook"/>

hello,
I have exactly the same problem. Have you found any solution?
Many thanks

CascadingDropDown incompatible with WebServices using GET?

I'm using a trio of cascadingdropdowns representing country/state/city throughout a web application I'm developing for a client. They've recently reduced their internet speed dramatically (from 7mbps to 728k) and suddenly I've had to become more concerned about bandwidth usage.

I'd like to switch my webservice to use GET so that client browsers can cache the results without re-requesting from the server, unfortunately when I try, my select boxes show the error: 12030 (occasionally 12031)

WebService Code:

1<Services.WebMethod(cacheduration:=60), Script.Services.ScriptMethod()> _2Public Function GetCountries(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As CascadingDropDownNameValue()3Dim cachedurationAs TimeSpan = TimeSpan.FromMinutes(1)4Dim maxageAs System.Reflection.FieldInfo = HttpContext.Current.Response.Cache.GetType().GetField("_maxAge", Reflection.BindingFlags.InstanceOr Reflection.BindingFlags.NonPublic)5 maxage.SetValue(HttpContext.Current.Response.Cache, cacheduration)6 Context.Response.Cache.SetCacheability(HttpCacheability.Public)7 Context.Response.Cache.SetExpires(Now.Add(cacheduration))8 Context.Response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate")9Dim cadapterAs New ltcodebehind.DSTablesTableAdapters.countryTableAdapter10Dim ctableAs New ltcodebehind.DSTables.countryDataTable11 cadapter.Fill(ctable)12Dim valuesAs New List(Of CascadingDropDownNameValue)13For iAs Integer = 0To ctable.Count - 114 values.Add(New CascadingDropDownNameValue(ctable(i).Title, ctable(i).ID))15Next1617 Return values.ToArray1819End Function

Client source code

1 <asp:ScriptManager runat="server" ID="acm1" >23 </asp:ScriptManager>4 <ajaxtoolkit:CascadingDropDown runat="server" ID="atlascascmgr" ServicePath="../Services/skService.asmx" SelectedValue="229" Category="country" ServiceMethod="GetCountries" TargetControlID="ddlcountry" />5 Country<br />6 <asp:DropDownList ID="ddlcountry" runat="server" />

Some notes

The only different on whether I receive an error 12030 is whether I have theusehttpget:=Truein the scriptmethod, so my cascadingdropdowns are configured properly for POST operations, I specifically need to know what I can change to get it to accept GET operations.

Usually its around this time that someone might offer up serverside caching, so I'm going to go ahead and answer that question now. 1) I appreciate the goodwill, I'm not being snarky, just trying to preemptively headd of the answer 2) I'm caching the webservice via the cacheduration:=60 up above, it just doesn't help because the server has power to spare, its the clients browsers that need the help.

Thanks everyone for their potential answers. :)

The third parameter to ASP.NET AJAX's Sys.Net.WebServiceProxy.invoke method is called "useGet" and tells it whether to use GET or POST for the web service call. The Toolkit's CascadingDropDownBehavior.js currently hard-codes this parameter to false (meaning "use POST"), so that's likely the source of the problem here. You should be able to change the value to true and rebuild for your client. If that works for you, pleaseopen a work item to ask that we expose this setting as a parameter to CascadingDropDown extender itself so that it will be easy to change for others who might want to do so. Thank you!

Very interesting, I'll do it when I have the time and if it works, open the work item like you describe.

Thanks!