Showing posts with label parent. Show all posts
Showing posts with label parent. Show all posts

Saturday, March 24, 2012

CascadingDropDownList fireEvent onchange not working when parent selection changed

I changed the included sample test page to remove the autopostback from theDropDownList3 dropdown (for color). I also removed the server side onselectedindxchanged eventhandler. I wanted to give the feedback to the user all from the client side. For that effect I added the following javascript code at the end of the page:

 <script type="text/javascript">$addHandler($get('<%=DropDownList3.ClientID%>'), "change", ProvideFeedback);function ProvideFeedback(eventElement){var makeDropdown = $get('<%=DropDownList1.ClientID%>');var modelDropdown = $get('<%=DropDownList2.ClientID%>');var colorDropdown = $get('<%=DropDownList3.ClientID%>');if(colorDropdown.selectedIndex == 0){alert("Please make all your selections");}else{alert('You selected ' + makeDropdown.options[makeDropdown.selectedIndex].text + ' - ' + modelDropdown.options[modelDropdown.selectedIndex].text + ' - ' + colorDropdown.options[colorDropdown.selectedIndex].text);}} </script>

It works just fine when I change the values in the color dropdown; I get the feedback. But I am also expecting to get the feedback when I change the make or model dropdown as the onchage is internally fired for color dropdown. But I never see that handled. Everytime I change values of make or model I never get the feedback.

Why is that? What am I missing?

Thanks.

Bumping up. Could someone please respond to this thread.

Ifthis.get_element().fireEvent('onchange'); is not producing the effect I am looking for what is it for?

Thanks.


Hi Nkv321,

CascadingDropDown will compare the selected value when its onchange event is fired. If no changes , there will no further actions , so it won't call the WebService.

I hope this helps.

Best regards,

Jonathan


It's not about changing the selected value and calling the web service. It's about when the parent value changes -- child drop down items get rebound -- and then an event is fired indicating that the child dropdown value has changed.

My question is what can that event be used for? How can it be used? I tried to use it in the sample that I put forth earlier but it was not executing. For example how can I add/attach a hanlder in the page to this event?

Thanks


Hi Nkv321,

I think you can attach a Javascript to the CascadingDropDown's add_selectionChanged or add_populated. For example:

function pageLoad(){$find("CascadingDropDown's BehaviorID"). add_selectionChanged(onSelectionChanged); }

function onSelectionChanged(){//your codes here.}

add_selectionChanged //Add an event handler for the selectionChanged event

add_populated //Add an event handler for the populated event

I Hope this help.

Best regards,

Jonathan

CascadingDropDownList and a MySQL database

How to use CascadingDropDownLists bound to a MySQL-database? I want a parent DDList with items selected from one table and a second DDlist with items selected from another table based on the value selected in the first one. But how to write the asmx-file?

Hi,

First, you can refer to this documentation for how to use it with a database. http://ajax.asp.net/ajaxtoolkit/Walkthrough/CCDWithDB.aspx

Then, as far as I know, MySql provides db driver for .net which can be used in a similar way as the build-in ADO.NET does. You can download it from their website and try to implement it according to the above documentation.

Hope this helps.

CascadingDropDown: How to register OnChange event on client?

Hello,

I have a WebForm with three CascadingDropDown. First is the parent of second list and second is the parent of the third list. And third list has a AutoPostBack feature to populate a GridView in an UpdatePanel on the page. My challenge is clear UpdatePanel content when user change first or second lists value.

So how can I register to onChange something like event of the list on client script? Then I can use $get("UpdatePanelClientId").innerHTML="".


Regards.

Hi,

You may use the following code.

<asp:DropDownList ID="DropDownList1" runat="server" Width="170"onchange="$get('ctl00_SampleContent_UpdatePanel1').innerHTML='';"/>

You can try it on the sample website's CascadingDropDown.aspx page.

Hope this helps.

Wednesday, March 21, 2012

CascadingDropDown Memoryleak, something with ParentControlID?

Hi, I'm currently using two cacadingdropdown extenders which retrieves data from webmethods (no webservices) embedded in aspx page. One is the parent of the other. And now each time I refresh the memory increases 800-1000K at the time. But the strange thing is that if i remove the parent child relationship (no extender has parentcontrolid defined) the memory leaks do not accur.

Am I doings something wrong, is something missing in webconfig?

12<!--34-->5<configuration>6<appSettings/>7<connectionStrings>8<add name="UtstyrConnectionString" connectionString="Data Source=WIN2003STDBASE;Initial Catalog=Utstyr;Integrated Security=True" providerName="System.Data.SqlClient"/>9</connectionStrings>10<system.web>11<pages enableEventValidation="false"></pages>1213<compilation debug="true">14<assemblies>15<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>16<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>1718<authentication mode="Windows"/>19 <identity impersonate="true"/>20 <authorization>21 <allow users="*"/>22 </authorization>23<httpHandlers>24<remove verb="*" path="*.asmx"/>25<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>26<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>27</httpHandlers>28<httpModules>29<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>30<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>31</httpModules>32</system.web>33</configuration>

Cheers GauteO

PS both my dropdownboxes and cacadingdropdownextenders are in an updatepanel

Here is a simple sample of what I mean. If anybody could run this to determine if it is a internal problem.

1<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>2<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc2" %>3<%@. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"4 Namespace="Microsoft.Web.UI" TagPrefix="asp" %>5<script runat="server">6 [System.Web.Services.WebMethod]7 [Microsoft.Web.Script.Services.ScriptMethod()]8 public static AjaxControlToolkit.CascadingDropDownNameValue[] Get(string knownCategoryValues, string category)9 {10 int count = 5;11 AjaxControlToolkit.CascadingDropDownNameValue[] cddnv = new AjaxControlToolkit.CascadingDropDownNameValue[count];12 for (int i = 0; i < count; i++)13 cddnv[i] = new AjaxControlToolkit.CascadingDropDownNameValue("Gaute" + i, i.ToString());14 return cddnv;15 }16 </script>17<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">18<html xmlns="http://www.w3.org/1999/xhtml" >19<head runat="server">20 <title>Untitled Page</title>21</head>22<body>23 <form id="form1" runat="server">24 <div>25 <asp:ScriptManager ID="ScriptManager1" runat="server">26 </asp:ScriptManager>27 <asp:DropDownList ID="DropDownList1" runat="server">28 </asp:DropDownList>29 <asp:DropDownList ID="DropDownList2" runat="server">30 </asp:DropDownList>31 <cc2:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="Valg" LoadingText="Laster" PromptText="Velg" ServiceMethod="Get" TargetControlID="DropDownList1">32 </cc2:CascadingDropDown>33 <cc2:CascadingDropDown ID="CascadingDropDown2" runat="server" Category="Velger" LoadingText="Laster" PromptText="Velg" ServiceMethod="Get" TargetControlID="DropDownList2" ParentControlID="DropDownList1">34 </cc2:CascadingDropDown>35 </div>36 </form>37</body>38</html>

This code gives me a memory leak of 700-1000k each time the page posts back. And if I remove the ParentControlId from CacadingDropDown2 (line 33) the memomry leaks stops. Testet the samplewebsite in ajaxtoolkit (cacadingdropdown) and that didn't have the memoryleaks. I have tried to elumate(copy) the procedure in the site, but cant stop the leaks.

GauteO


*bump*

also tried with RC1 release, same problem..


What Browser are you testing with? Or is this problem occuring in all browsers?

The reason I ask, is that I found that several issues with the CascadingDropDowns disappeared when I moved to IE 7.0. For example, with IE 6.x I have found that having two different sets of CascadingDropDowns on the same page will break the functionality of the SelectedValue tags... Only the first set of CascadingDropDowns will get the correct initial value...


Currently I have only testet with ie6, I shall test on other browser when I get to work again (as I'm currently home). I usally test in opera, firefox, ie6 and ie7+(vista browser). But I am really cursious if anybody else get this memory leak when one of the cascadingdropdown extenderes has an parentcontrolid assign to it, and stops when none have an parentcontrolid. They provide/retrieves the same information in both instances, only diffrence that the cacadingdropdown with parentcontrolid has the "knownvalues" of its parent (and 700-1000k is pretty much for 5 values beeing sent, as in the sample in the second post). Maybe I must embed the information in XML (as they do in the sample site ajaxcontrolkit)?

Hmm, I have testet the scenario on opera and ie7+ and the memory leaks do not accur. I also testet the sitehttp://ajax.asp.net/ajaxtoolkit/CascadingDropDown/CascadingDropDown.aspx again, with ie6, and the memory leak problem accurs there too (was sure that I tested this before and didn't have the problem, it was beta2 not rc1 which I testet now). It seems that ie6 is the problem, I am running 2003 server on a virtual pc(vmware), but it does not have the latest updates (trying to install them, but windows update just stops). Maybe this problem only accurs on old versions of ie6 (IE that follows a clean install of 2003 server), if anybody could confirm this it would be of great help (use the cacadingdropdown example on the ajaxcontrolkit website). My current version of ie6 is:

GauteO


That this doesn't happen in other browsers (including IE7) suggests to me that it's probably not something the Toolkit is doing wrong. Please let us know what happens with an updated IE6.

cascadingdropdown many child share one parent, child of child

I have 6 cdd structured as follows

cdd 1 (top most)

cdd 2 -> parent = 1

cdd 3 -> parent = 2

cdd 4 -> parent = 2

cdd 5 -> parent = 2

cdd 6 -> parent = 5

As you can see 3, 4 & 5 share the same parent. This works fine and all drop down populate = great ! When I add 6, where the parent is one of the children that share a parent, IE does not respond. If I click on the page I get (Not Responding) in the title bar and if I keep clicking I get the popup "The script is causing internet explorer to run slowly do you want to abort the script".

Code is here...

<ajaxToolKit:CascadingDropDownID="cddState"runat="server"TargetControlID="ddState"

Category="State"LoadingText="[Loading states...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True">

</ajaxToolKit:CascadingDropDown>

<ajaxToolKit:CascadingDropDownID="cddSuburb"runat="server"TargetControlID="ddSuburb"

Category="Suburb"LoadingText="[Loading suburbs...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True"ParentControlID="ddState">

</ajaxToolKit:CascadingDropDown>

<ajaxToolKit:CascadingDropDownID="cddHomeDrive"runat="server"TargetControlID="ddHomeDrive"

Category="HomeDrive"LoadingText="[Loading drives...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True"ParentControlID="ddSuburb">

</ajaxToolKit:CascadingDropDown>

<ajaxToolKit:CascadingDropDownID="cddProfilePath"runat="server"TargetControlID="ddprofilepath"

Category="ProfilePath"LoadingText="[Loading paths...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True"ParentControlID="ddSuburb">

</ajaxToolKit:CascadingDropDown>

<ajaxToolKit:CascadingDropDownID="cddExchangeServer"runat="server"TargetControlID="ddExchangeServer"

Category="ExchangeServer"LoadingText="[Loading servers...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True"ParentControlID="ddSuburb">

</ajaxToolKit:CascadingDropDown>

<ajaxToolKit:CascadingDropDownID="cddMailStorageGroup"runat="server"TargetControlID="ddMailStorageGroup"

Category="MailStore"LoadingText="[Loading stores...]"PromptText="-Please Select-"

ServiceMethod="GetTechnicalComboValues"ServicePath="Services\CascadeCombo.asmx"

Enabled="True"ParentControlID="ddExchangeServer">

</ajaxToolKit:CascadingDropDown>

Thanks

Was this ever resolved? I'm having a very similar problem.

Here's my scenario:

cdd1 (top-most)

cdd2 -> parent = 1

cdd3 -> parent = 1

cdd4 -> parent = 1

cdd5 -> parent = 4

Now I get the same problem as you: IE6 unresponsive and later the message "A script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?".

Note that I don't have this issue if I remove cdd5 (leaving 1, 2, 3, 4) or if I remove cdd2 (leaving 1, 3, 4, 5) or if I remove cdd3 (leaving 1, 2, 4, 5). So it appears that what's common with your scenario is that if you have three CascadingDropDowns dependent on a given CDD and another CDD dependent on one of the three level2 CDDs, the web page hangs with the above errors.

Thanks for any insight you can give.

-Wayne


Yes I resoved this (by workaround), I apologise for not updating my post.

It comes down to the order the cascading controls appear in the markup (note: not the combo boxes BUT the cascading extenders themselves).

What you need to is to position cdd4 above cdd3 so you end up with this:

cdd1 (top-most)

cdd2 -> parent = 1

cdd4 -> parent = 1

cdd3 -> parent = 1

cdd5 -> parent = 4

As I indicated above the change is only how they appear in the markup. Your cascading relationships and combo boxes themselves dont change. I hope this makes sense.

This sent me crazy... with no replies to my original post it was only by fluke that I discovered this behaviour.

I hope you have success.


Wow! It works.

Thanks very much for the help!

Did you experience any other gotchas using the CascadingDropDownExtender? Initially, I was planning on using standard asp DropDownLists with Ajax UpdatePanels, instead of the CascadingDropDownExtender. However, this is not possible in a FormView if you name your controls the same in both InsertItemTemplate and UpdateItemTemplate. (Here's a post on this problem: http://forums.asp.net/p/1058745/1570069.aspx) I had decided that if I couldn't get the CascadingDropDownExtender to work, I'd just use the UpdatePanels in the template most used for this app. If you know of any other issues with this extender, I'd appreciate finding out. Seems like your scenario might be somewhat similar to mine. I assume you're doing inserts and updates with the dropdowns on which you had the problem?

Thanks again for the help!


The only other problem I had was populating a cascading set via Javascript. There are a number of articles on this but I couldn't get it to work.

The scenario I had was select a State and then select a suburb. The suburb would populate based on the state selected = standard stuff.

I had a copy function that copied these values from another record and I wanted to use Javascript to avoid a postback. I could set the state value but I couldn't set the suburb value.