Showing posts with label sample. Show all posts
Showing posts with label sample. Show all posts

Monday, March 26, 2012

CascadingDropDowns in VB

I'm trying to convert the CascadingDropDown list sample to VB and I'm running into a problem. When I view the page, there are no errors but the dropdown lists don't populate. It doesn't seem like the webservice is being run. The reason I say this is beacuse if I change the "ServicePath" property on the aspx page to point to a nonexistant file, I get the exact same results...No error and no data in the lists. But I figure that if the ServicePath that Im pointing at doesn't exist, I should be getting an error. Here is my code for the .vb service and the .aspx code. What am I missing?

Inherits System.Web.Services.WebServicePrivate ReadOnly _document asNew XmlDocument()Private ReadOnly _hierarchy() asString Public Sub CarsService()'Read XML data from disk _document.Load(Server.MapPath("~/App_Data/CarsService.xml")) _hierarchy(0) ="Make" _hierarchy(1) ="Model"End Sub <WebMethod()> _Public Function GetDropDownContents(ByVal knownCategoryValuesAs String,ByVal categoryAs String)As AtlasControlToolkit.CascadingDropDownNameValue()Dim knownCategoryValuesDictionary asNew StringDictionary knownCategoryValuesDictionary = AtlasControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)Return AtlasControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(_document, _hierarchy, knownCategoryValuesDictionary, category)End Function
<atlas:ScriptManager id="ScriptManager1" EnablePartialRendering="true" runat="server"></atlas:ScriptManager> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"><contenttemplate><table><tr> <td>Make</td> <td><asp:DropDownList ID="DropDownList1" runat="server" Width="170" /></td></tr><tr> <td>Model</td> <td><asp:DropDownList ID="DropDownList2" runat="server" Width="170" /></td></tr><tr> <td>Color</td> <td><asp:DropDownList ID="DropDownList3" runat="server" Width="170" /></td></tr></table><br /><asp:Button ID="Button1" runat="server" Text="I want this car" OnClick="Button1_Click" /><br /><br /><asp:Label ID="Label1" runat="server" Text="[No response provided yet]"></asp:Label></contenttemplate></atlas:UpdatePanel><atlasToolkit:CascadingDropDown id="CascadingDropDown1" runat="server"><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList1" Category="Make"PromptText="Please select a make" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents" /><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList2" Category="Model"PromptText="Please select a model" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"ParentControlID="DropDownList1" /><atlasToolkit:CascadingDropDownProperties TargetControlID="DropDownList3" Category="Color"PromptText="Please select a color" ServicePath="CarsService.asmx" ServiceMethod="GetDropDownContents"ParentControlID="DropDownList2" /></atlasToolkit:CascadingDropDown></form>

Hmmm - the code looks okay to me. Two questions:

1) Does the sample website page for CascadingDropDown work okay?

2) If you put a breakpoint in the web service, can you verify that it does or doesn't work


Make sure that your Web.Config is updated to allow browser access to web services. You can find details at this link:

http://atlas.asp.net/docs/atlas/doc/services/exposing.aspx#enable

If you don't then I think you'll find that your drop-down lists will not be populated!

Hope this helps

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

CascadingDropDown Work only locally

HI,

I basically followed the sample toolkitCascadingdropdown. i only need 2 dropdown lists - Country and State.

everything works find on both local and live server. but when I'm calling the webservice from another website it has problems - a javascript error

<asp:DropDownList ID="ddlCountry" runat="server" />
<asp:DropDownList ID="ddlState" runat="server" />

<ajaxtoolkit:cascadingdropdown id="CascadingDropDown1" runat="server" category="State" loadingtext="Please wait..." parentcontrolid="ddlCountry" prompttext="Select a country"
servicemethod="GetStatByCountryID" servicepath="http://www.domainname.com/WebService/AddressService.asmx" targetcontrolid="ddlState">
</ajaxtoolkit:cascadingdropdown>

all sample I've seen is for working locally - both dropdownlists and webservice are sitting in the same website.

wondering if anyone can show me show to implement this cascadingdropdown by calling an external webservice

much appreciated

Hi,

So your intention is to call a external web service?

XmlHttpRequest object can't access external web service directly for security reasons. So, you may achieve this by adding a web service in the same domain, and this web service calls the external service. On client side, use this new web service to access the external web service indirectly.

Hope this helps.


This is exactly what I did, works out perfectly.

I created a local webserivce calling the external one.

much appreciated for your reply.

Wednesday, March 21, 2012

CascadingDropDown Sample problem, Method Error 500

Hi

I've downloaded the last version of Control Toolkit and I've installed it. When I try to run the WebSampleSite, everything works fine except CascadingDropDown, The first combo says "Method Error 500". Any ideas?

Please help...

to me Method Error 500 is webservices error

try look webservices area..make sure it gets call (you can debug into it)

CascadingDropDown require EventVlidation=false?

I turned on event validation (=true) of the Atlas Control Toolkit sample -> CascadingDropDown .

When I click the , Error message suggest turn event validation off.

Is this a must?

I saw some thread showing that they can add an attribute "SuppressEventValidation", but I can't see smart tag/ code hints in my version? Is it a new feature in later built of atlas?

Please advice how to keep EventValidated ?

This thread explains why I believe EnableEventValidation needs to be false:http://forums.asp.net/thread/1281139.aspx

Thanks for your kindly reference, It's really a time for me to choose between SECURITY , USABLITILY

I need to sacrifice security , choose usablitiliy

CascadingDropDown items limited (Error) ??

Hello people,

I have a big problem with CDD, try to load a large amount of items, for example.

In the sample of CDD change the webservice "CarsService" method "GetDropDownContents",
insert this code:

for (int i = 0; i < 870; i++)
{
values.Add(new CascadingDropDownNameValue(string.Format("Name{0}",i), string.Format("Value{0}",i)));
}

and the Method Erro 500 show ...

my list are 890 items

Please Help...!Idea

What is the exact error you are getting? Is it possible to figure out at what exact number of items cdd starts to error out?

Also, what is the scenario in which you need to have so many items in a cdd? From a usability point of view it does not seem very appropriate.


Try:http://ajax.asp.net/docs/mref/P_System_Web_Script_Serialization_JavaScriptSerializer_MaxJsonLength.aspx

Thank you so much for your response...

Solve my problem perfect...Yes

Big Smile