Hello,
I did some research but couldn't find a solution and I hope you can help me.
The DropDownList (there are more, but one will suffice) is populated correctly, at least when I click on it.
<asp:HiddenField ID="SomeID" OnValueChanged="VC_Method" runat="server" />
<div id="hiddenForm" style="display :none">
<asp:UpdatePanel ID="DetailUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="False" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ProjectDDL" runat="server"></asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CDD0" TargetControlID="ProjectDDL" Category="Project" ServicePath="CDD.asmx" ServiceMethod="GetProjects" runat="server" />
So now what this should do is, when clicking on a Link the DetailUpdatePanel becomes visible and the VC_Method of the HiddenField is executed and in this Method I want to select a certain item of the DDL. But there are no values to choose from. Now my question is, becomes the CDD only populated when I click on it and if so, how can I populate it beforehand?
Thanks in advance.
I solved the problem above, but I'm now terribly stuck.
After the user selected one item from the first dropdownlist, the second becomes active etc. Now the user decides to cancel the task and for wathever reason he starts anew. My problem now is, that I want to reset the cascading dropdownlist on client side, so that the user can only select items from the first dropdownlist. For this purpose a javascript function should be executed. I can set the dropdownlist to the value I want and also the cascading dropdownlist, but it won't affect the second and third. Thus they stay active with wrong information.
I have tried now for one day hand havn't got a clue. Please help me..
EDIT:corrected some errors
Hi Twinkybot,
My understanding of your issue is that you want the second CascadingDropDown not change while you selected the first CascadingDropDown. If I has misunderstood, please feel free to let me know.
Based on this knowledge, I think you can remove the handlers of the first CascadingDropDown and then remove the second CascadingDropDown's _parentChangeHandler. Here is the sample.
<%@. Page Language="C#" EnableEventValidation="false" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{
}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="../WebService/CityServiceOledb.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager>
State:<asp:DropDownList runat="server" ID="dlState">
</asp:DropDownList>
City:
<asp:DropDownList runat="server" ID="dlCity" AutoPostBack="true">
</asp:DropDownList>
<cc1:CascadingDropDown ID="CascadingDropDown1" BehaviorID="myCDEState" runat="server" TargetControlID="dlState"
Category="State" ServicePath="../WebService/CityServiceOledb.asmx" ServiceMethod="GetStates" LoadingText="[Loading...]" PromptText="Please select state" UseContextKey="true" ContextKey="0,0">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown2" BehaviorID="myCDECity" runat="server" TargetControlID="dlCity" ParentControlID="dlState"
Category="City" PromptText="Select a city" ServicePath="../WebService/CityServiceOledb.asmx"
ServiceMethod="GetCities" LoadingText="Load Text..." >
</cc1:CascadingDropDown>
<input id="Button2" type="button" value="remove" onclick="removeCascading();"/>
<asp:Button ID="Button1" runat="server" Text="Button" />
<script type="text/javascript" language="javascript">
function removeCascading(){
$find("myCDEState").dispose();
$removeHandler($find("myCDECity")._parentElement, "change", $find("myCDECity")._parentChangeHandler);
$get("Button2").disabled = true;
}
</script>
</form>
</body>
</html>
Best regards,
Jonathan
Yes, I think you misunderstood. I want the second and third CascadingDropDown to change according to the selcetion of the first. But the Problem is, that it doesn't.
I try to explain my problem better. The user selects one item in the first DropDownList. The second becomes updated and the user is able to select one item. Now he cancels the changes and restarts the procedure.
What I want now is, that after hitting the cancel-Button, the DropDownLists must reset. I.e. in a Javascript I set the selectedIndex for the first DropDownList to 0. Corresponding to this selection the second and third should now change themselves, but it doesn't happen.
<asp:DropDownList ID="ProjectDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown0" TargetControlID="ProjectDropDownList" Category="Project" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetProjects" runat="server" /><asp:DropDownList ID="TaskDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" TargetControlID="TaskDropDownList" ParentControlID="ProjectDropDownList" Category="Task" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetTaskForProject" runat="server" /> <asp:DropDownList ID="TaskShortDescriptionDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" TargetControlID="TaskShortDescriptionDropDownList" ParentControlID="TaskDropDownList" Category="TaskDescription" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetDescriptionForTask" runat="server" />
function clearForm(){ var projectDDL = document.getElementById('<%= ProjectDropDownList.ClientID%>'); projectDDL.selectedIndex = 0; //Here must be something to activate the cascade}
I found a solution and I will post this for other desperate people.
projectDropDownList.options[0] = new Option(projectName, projectId, true, false);
taskCascade._onParentChange(null, false);
No comments:
Post a Comment