Wednesday, March 21, 2012

CascadingDropDown OnSelectedIndexChanged event not firing

Help!!!

I have 4 drop down list boxes that are extended by the CascadingDropDown control. All of the controls populate in sequence. I am using the OnSelectedIndexChanged event of the 4th DDL to trigger an UpdatePanel. I want to take the selection from the DDL (cmbPart) and add the item to the ListBox (lbParts). When I change the selection in cmbPart, no event fires. When I press the button on the panel (btnRemovefromList) the cmbPart_SelectedIndexChanged event DOES fire before the btnRemovefromList_Click event. I have also tried to use OnSelectedIndexChanged to fire a client side javascript function and that does not fire either. However, the onblur and onclick events DO fire.

According to previous posts on this topic, it was fixed. I have the 1.0.60914.0 version of the AtlasControlToolkit.dll installed along with version 2.0.50727.60725 of Microsoft.Web.Atlas.dll.

Ken J.

Here is the code:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"EnableEventValidation="false"%>

<%@dotnet.itags.org.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<div>

Year<asp:dropdownlistid="cmbFrom"tabIndex="2"runat="server"Width="120px">

</asp:dropdownlist>

<atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server">

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbFrom"

Category="Year"

LoadingText="{Loading Years...}"

PromptText="Select a Year"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetYears"

/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbMake"

ParentControlID="cmbFrom"

Category="Make"

LoadingText="{Loading Makes...}"

PromptText="Select a Make"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetMakes"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbModel"

ParentControlID="cmbMake"

Category="Model"

LoadingText="{Loading Models...}"

PromptText="Select a Model"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetModels"/>

<atlasToolkit:CascadingDropDownProperties

TargetControlID="cmbPart"

ParentControlID="cmbModel"

Category="Part"

LoadingText="{Loading Parts...}"

PromptText="Select Parts"

ServicePath="EOLDataService.asmx"

ServiceMethod="GetParts"/>

</atlasToolkit:CascadingDropDown>

Make<asp:dropdownlistid="cmbMake"tabIndex="3"runat="server"Width="215px"></asp:dropdownlist>

Model<asp:dropdownlistid="cmbModel"tabIndex="4"runat="server"Width="250px"></asp:dropdownlist>

<INPUTid="txtPartType"type="hidden"runat="server"NAME="txtPartType">

<asp:labelid="lparterr"runat="server"Width="216px"ForeColor="Red"></asp:label>

<atlas:UpdatePanelID="upParts"runat="server"Mode="conditional">

<ContentTemplate>

Part<asp:DropDownListID="cmbPart"runat="server"Width="250px"OnSelectedIndexChanged="cmbPart_SelectedIndexChanged"></asp:DropDownList>

Selected Parts<asp:ListBoxid="lbSelected"tabIndex="10"runat="server"Width="215px"Height="85px"SelectionMode="Multiple"></asp:ListBox>

<asp:Buttonid="btnRemovefromList"style="WIDTH: 54px; font-size:xx-small"tabIndex="9"Text="Remove"

runat="server"onclick="btnRemovefromList_Click"/>

</ContentTemplate>

<Triggers>

<atlas:ControlEventTriggerControlID="cmbPart"EventName="SelectedIndexChanged"/>

<atlas:ControlEventTriggerControlID="btnRemoveFromList"EventName="Click"/>

</Triggers>

</atlas:UpdatePanel>

</div>

</form>

<scripttype="text/xml-script">

<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">

<references>

</references>

<components>

</components>

</page>

</script>

</body>

</html>

And the code behind:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid cmbPart_SelectedIndexChanged(object sender,EventArgs e)

{

lparterr.Text ="test";

}

protectedvoid btnRemovefromList_Click(object sender,EventArgs e)

{

lparterr.Text ="Test";

}

}

Maybe have a look atthis post?

Thanks David.

I found that the final DDL had to have AutoPostBack set to true. I also found that using the UpdatePanel to contain only the control I want updated by the ControlEventTrigger. If the DDL controls are contained in the UpdatePanel you will see the CascadingDropDown extender refresh each of the DDLs.

Ken J.

No comments:

Post a Comment