Wednesday, March 21, 2012

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.

No comments:

Post a Comment