Hi
I'm trying to use the CascadingDropDown with a database in VB, using page methods.
My three DropDownLists are drpProject, drpFixFor and drpFixForSub. The drpProject control is populated fine when the page loads; and I'd expect the drpFixFor control to be populated when drpProject is changed, however, this is not happening.
The drpFixFor control is being enabled, but not populated - my "GetFixForList" function doesn't appear to be calledat all. (I put a breakpoint in it, and the breakpoint isn't hit.)
Interestingly, if I remove ParentControlID="drpProject" from drpFixFor's extender, the function is called as expected when the page loads.
My aspx page is:
<%
@dotnet.itags.org.PageLanguage="VB"MasterPageFile="~/MasterPage.master"AutoEventWireup="false"CodeFile="Test.aspx.vb"Inherits="Test"Title="" %><%
@dotnet.itags.org.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %><
asp:ContentID="Content1"ContentPlaceHolderID="cphBody"runat="Server"><table> <tr> <tdstyle="width: 100px">Project:</td> <td><asp:DropDownListID="drpProject"runat="server"/></td> </tr> <tr> <tdstyle="width: 100px">Fix For:</td> <td><asp:DropDownListID="drpFixFor"runat="server"/></td> </tr> <tr> <tdstyle="width: 100px">Fix For Sub:</td> <td><asp:DropDownListID="drpFixForSub"runat="server"/></td> </tr></table><atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"> <atlasToolkit:CascadingDropDownPropertiesTargetControlID="drpProject"Category="Project"PromptText="(Select One)" ServiceMethod="GetProjectList"/> <atlasToolkit:CascadingDropDownPropertiesTargetControlID="drpFixFor"Category="FixFor"PromptText="(Select One)"ParentControlID="drpProject"ServiceMethod="GetFixForList"/> <atlasToolkit:CascadingDropDownPropertiesTargetControlID="drpFixForSub"Category="FixForSub"PromptText="(Select One)"ParentControlID="drpFixFor"ServiceMethod="GetFixForSubList"/></atlasToolkit:CascadingDropDown>
</
asp:Content>And my Code Behind page is:
Imports
AtlasControlToolkitImports
System.Web.ServicesPartial
Class Test Inherits System.Web.UI.Page<WebMethod()> _
PublicFunction GetProjectList(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue() Dim valuesAsNew Generic.List(Of CascadingDropDownNameValue) ForEach myProjectAs ProjectIn Project.GetListvalues.Add(
New CascadingDropDownNameValue(myProject.Name, myProject.ID)) Next Return values.ToArray EndFunction<WebMethod()> _
PublicFunction GetFixForList(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue() Dim valuesAsNew Generic.List(Of CascadingDropDownNameValue) ' Hardcode to Project "2" for debugging ForEach myFixForAs FixForIn FixFor.GetList(2)values.Add(
New CascadingDropDownNameValue(myFixFor.Name, myFixFor.ID)) Next Return values.ToArray EndFunctionEnd
ClassNote: "Project" and "FixFor" are objects defined in my App_Code folder, and their "GetList" functions return data from the SQL database.
Any ideas?
Thanks,
Andrew
I am also facing some issues with the cascadingdropdown extender, my question is that what if my database schema is such that i dont have ID for the fields in the drop downs, cant i fetch the value in the second drop down with the string value in the first drop down. As i understand this, ID seems to be added mandatorily in this extender.
-Pratibha
I don't see anything wrong with your code - what happens if you change all three service method's to call the one that's workng? Does it get called then?
Pratibha - I don't understand your question. ID isn't added by the extender at all - you can put whatever you want into the value field of the CascadingDropDownNameValue.
hey shawn, now i get it..hadnt looked carefully through the tool kit code earlier. It makes sense now and the cascadingdropdown works perfectly :)
Cool!
Hi
I've tried setting all three service methods to call GetProjectList, and still no luck - the function's called once when the page is loaded to populate the first DropDown, and not called for the others.
Thanks,
Andrew
To fix this, you need to add EnableEventValidation="false" to your Page directive. This should be a FAQ for CascadingDropDown, but basically ASP.NET tries to make sure that postbacks don't contain stuff they shouldn't based on what it knows about the page it sent down. Well, CDD is all about sending back data that wasn't in the page to begin with, so this feature needs to be disabled for pages that use it.
That's the good news. :) The bad news (or better news depending on how you see it) is that this should have been easier to debug. CDD tries to populate the list with error details when an error occurs (see _onMethodError), but it doesn't because a change some time ago to use name/value pairs for the data type wasn't applied to the error methods. I've logged this for fixing in the next release.
But for now, your issue should be trivially solvable by flipping EnableEventValidation as I note above.
Thanks!
Fantastic - that did the job!
Thanks
Andrew
nice1 David,
that had really thrown me, thought it was a vb.net thing. the debugging experience on this could definitely be improved on but at least it's in the forums.
thanks
I've been trying to get this example to work so as I can use similar in my own pet project.
Would anyone be kind enough to tell\show me how to create the "Projects" and "FixFor" objects which are defined in the App_Code folder.
I'm getting errors on this lineForEach myProjectAs ProjectIn Project.GetData
How do I define Project in the TableAdapter?
Rgds
DOShea
Hi,
My parent dropdown itself is not population. I addedEnableEventValidation="false" in page tag. Still no luck.
If i work in " atlas web project", I am able sccess with cascading dropdown. But if i try to do with existing project, i am not able to. No error but first dropdown itself not populating.
I added in web.config
<
pages><
controls><
addnamespace="Microsoft.Web.UI"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/><
addnamespace="Microsoft.Web.UI.Controls"assembly="Microsoft.Web.Atlas"tagPrefix="atlas"/></
controls>...
</
pages>This is my aspx page code:
<%
@.PageLanguage="VB"AutoEventWireup="true"CodeFile="Default.aspx.vb"Inherits="_Default"EnableEventValidation="false" %><%
@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %><formid="form1"runat="server"><atlas:ScriptManagerID="ScriptManager1"runat="server"/><div><asp:DropDownListID="DropDownList1"runat="server"></asp:DropDownList><asp:DropDownListID="DropDownList2"runat="server"></asp:DropDownList></div><atlasToolkit:CascadingDropDownID="CascadingDropDown1"runat="server"><atlasToolkit:CascadingDropDownPropertiesTargetControlID="DropDownList1"Category="Make"PromptText="Please select a make"ServiceMethod="GetDropDownContentsPageMethod"/><atlasToolkit:CascadingDropDownPropertiesTargetControlID="DropDownList2"Category="Model"PromptText="Please select a model"ServicePath="CarService.asmx"ServiceMethod="GetProductGroups"ParentControlID="DropDownList1"/></atlasToolkit:CascadingDropDown></form>.Vb File:
<WebMethod()> _
PublicFunction GetDropDownContentsPageMethod(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)
values.Add(
New CascadingDropDownNameValue("A","1"))values.Add(
New CascadingDropDownNameValue("B","2"))values.Add(
New CascadingDropDownNameValue("C","3"))Return values.ToArrayEndFunction
My WebService (CarService.vb):
<WebMethod()> _
PublicFunction GetProductGroups(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()Dim kvAs StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)Dim ProvinceIdAsIntegerIf (kv.ContainsKey("Make")And Int32.TryParse(kv("Make"), ProvinceId))ThenIf ProvinceId = 1Thenvalues.Add(
New CascadingDropDownNameValue("a","1"))ElseIf ProvinceId = 2Thenvalues.Add(
New CascadingDropDownNameValue("b","1"))EndIfEndIfReturn values.ToArrayEndFunctionAny help is highlyAppreciated.
Regards
kant.
My reply from the private email about this issue:
"The web.config for an Atlas has additional settings that aren't present in a default web.config. It sounds like you need to add one or more of those settings to your site's web.config. You might find the windiff utility helpful in identifying the changes. Hope this helps!"
Thanks David. I am able to solve by adding aditional attributes.
I have another prob with in the same page. I added a gridview to that page having Edit & Delete buttons.
When ever my page is postback(by clicking button or by grid events ) , it's refreshing twice. Any Idea?
I am usingCollapsiblePanel, CascadingDropDownin that page.
kindly reply me if you come across this probulem.
Regards
Kant.
Hi,
This is my scenario.
In production server (win2003 with IIS 6.0, asp.net 2.0 and asp.net 1.1 coexist),
My drop downs appear blank if I try to use web services to provide the data.
If I use built in page methods and I got 'sys' is undefined.
In development pc, (XP with IIS 5.1, asp.net 2.0 and asp.net 1.1 coexist),
Both web services and page methods work without any problem.
Web.config in both machine were identical.
Does anyone have any idea why?
Thanks in advance.
Michael
"Sys undefined" suggests that Atlas itself may not be installed/configured correctly on that server.
No comments:
Post a Comment