Hey, I have a rather annoying problem with the cascading dropdownlists from the AJAXtoolkit. I have 3 (Country, State, City) and they all work on my lap, but when I upload its only the first one loading the others are just blank... not even a 'method error 500' or anything. I use a webservice and the service is located in root of the app. Anyone got a clue about what there can be wrong? Thank you in advance. Regards, Mark
Hi wisemx, thanks for your reply. All the 3 points are wokring fine, since the first ddl (Country) works fine and gets the correct values from the DB, but the remaining (Children - State and City) are just blank. <%@ Page Language='C#' MasterPageFile='~/Default.master' AutoEventWireup='true' CodeFile='Calculator.aspx.cs' Inherits='Calculator' Title='' EnableEventValidation='false' Culture='en-GB' UICulture='en-GB' %> <%@ Register Assembly='AjaxControlToolkit' Namespace='AjaxControlToolkit' TagPrefix='ajaxToolkit' %> <asp:Content ID='Content1' ContentPlaceHolderID='Contentplaceholder1' runat='Server'> <asp:ScriptManager ID='ScriptManager1' EnablePartialRendering='true' runat='server' > <Services> <asp:ServiceReference Path='~/LocationServices.asmx' /> </Services> </asp:ScriptManager> <div id='pageCalculatorAdmin'> <asp:UpdatePanel ID='UpdatePanel1' runat='server'> <ContentTemplate> <table style='margin-top: 20px;' border='0' cellpadding='4' cellspacing='0'> <tr> <td class='tblColumHeader' colspan='2'> Data for your shipment:</td> </tr> <tr> <td class='tdHeaderEven' style='width: 130px;'> Country</td> <td class='tdEven' style='width: 170px;'> <aspropDownList ID='ddlCountries' runat='server' Width='170'> </aspropDownList> </td> <td style='width: 30px; text-align: left'> <asp:RequiredFieldValidator ID='rfvCountry' ControlToValidate='ddlCountries' runat='server' ErrorMessage='Please select a Country.' Style='position: relative'>*</asp:RequiredFieldValidator> </td> </tr> <tr> <td class='tdHeaderUneven' style='width: 130px;'> State</td> <td class='tdUneven' style='width: 170px;'> <aspropDownList ID='ddlStates' runat='server' Width='170'> </aspropDownList> </td> <td style='width: 30px; text-align: left'> <asp:RequiredFieldValidator ID='rfvState' ControlToValidate='ddlStates' runat='server' ErrorMessage='Please select a State.' Style='position: relative'>*</asp:RequiredFieldValidator> </td> </tr> <tr> <td class='tdHeaderEven' style='width: 130px;'> City</td> <td class='tdEven' style='width: 170px;'> <aspropDownList ID='ddlCities' runat='server' Width='170'> </aspropDownList> </td> <td style='width: 30px; text-align: left'> <asp:RequiredFieldValidator ID='rfvCity' ControlToValidate='ddlCities' runat='server' ErrorMessage='Please select a City.' Style='position: relative'>*</asp:RequiredFieldValidator> </td> </tr> ..... ..... </tr> </table> <ajaxToolkit:CascadingDropDown ID='CascadingDropDown1' runat='server' TargetControlID='ddlCountries' Category='Country' PromptText='Please select a Country' LoadingText='[Loading countries...]' ServicePath='~/LocationServices.asmx' ServiceMethod='GetCountries' /> <ajaxToolkit:CascadingDropDown ID='CascadingDropDown2' runat='server' TargetControlID='ddlStates' Category='State' PromptText='Please select a State' LoadingText='[Loading states...]' ServicePath='~/LocationServices.asmx' ServiceMethod='GetStatesByCountry' ParentControlID='ddlCountries' /> <ajaxToolkit:CascadingDropDown ID='CascadingDropDown3' runat='server' TargetControlID='ddlCities' Category='City' PromptText='Please select a City' LoadingText='[Loading cities...]' ServicePath='~/LocationServices.asmx' ServiceMethod='GetCitiesByState' ParentControlID='ddlStates' /> .... .... Any help is greatly appriciated. Thanks, Mark
Not a problem bro, btw my name is also Mark, which makes talking to Mark kinda strange. Take a look at this example: http://ajax.asp.net/ajaxtoolkit/CascadingDropDown/CascadingDropDown.aspx Notice how your first CascadingDropDown is using the wrong TargetControlID? Go back over the example and you should be able to get this working in no time.
Oh, well from one Mark to another then /emoticons/smile.gif ... why does it work locally then? /emoticons/sad.gif
I'd have to see more to tell but my guess is you just think it's working because they populate. That however tells me there may be a problem with the data objects, which may not have been uploaded. Object data sources are awesome but they can make things like this tricky to diagnose. Salute, Mark Wisecarver aka wisemx
I'm totally confused now... I removed the parent ID of the c-ddl's and then they populated, but of course without any data (missing parameters)... Is there maybe a problem with calls to parents and the permissions of webservices... it must be a folder setting or something in the machine config since it works locally and not online right? My web service.. [WebService(Namespace = 'http://tempuri.org/')] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService()] public class LocationServices : System.Web.Services.WebService { /// <summary> /// Constructor to initialize members /// </summary> public LocationServices() { } [WebMethod] public AjaxControlToolkit.CascadingDropDownNameValue[] GetCountries(string knownCategoryValues, string category) { using (OleDbConnection connection = new OleDbConnection(Common.AccessConnection)) { using (OleDbCommand command = new OleDbCommand('SELECT DISTINCT FREIGHT.Destination_Country AS Country FROM FREIGHT;', connection)) { command.CommandType = CommandType.Text; connection.Open(); List<AjaxControlToolkit.CascadingDropDownNameValue> countries = new List<AjaxControlToolkit.CascadingDropDownNameValue>(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { countries.Add(new AjaxControlToolkit.CascadingDropDownNameValue((string)reader['Country'], (string)reader['Country'])); } } connection.Close(); return countries.ToArray(); } } } [WebMethod] public AjaxControlToolkit.CascadingDropDownNameValue[] GetStatesByCountry(string knownCategoryValues, string category) { string[] values = knownCategoryValues.Split(':', ';'); string countryCode = ''; for (int i = 0; i < values.Length; i++) { if (values == 'Country') countryCode = values[i + 1]; } using (OleDbConnection connection = new OleDbConnection(Common.AccessConnection)) { using (OleDbCommand command = new OleDbCommand('SELECT DISTINCT US_DELIVERY.State FROM US_DELIVERY WHERE (((US_DELIVERY.Country)=\'' + countryCode + '\')) ORDER BY US_DELIVERY.State;', connection)) { command.CommandType = CommandType.Text; connection.Open(); List<AjaxControlToolkit.CascadingDropDownNameValue> states = new List<AjaxControlToolkit.CascadingDropDownNameValue>(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { states.Add(new AjaxControlToolkit.CascadingDropDownNameValue((string)reader['State'], (string)reader['State'])); } } connection.Close(); return states.ToArray(); } } } [WebMethod] public AjaxControlToolkit.CascadingDropDownNameValue[] GetCitiesByState(string knownCategoryValues, string category) { string[] values = knownCategoryValues.Split(':', ';'); string state = ''; for (int i = 0; i < values.Length; i++) { if (values == 'State') state = values[i + 1]; } using (OleDbConnection connection = new OleDbConnection(Common.AccessConnection)) { using (OleDbCommand command = new OleDbCommand('SELECT DISTINCT US_DELIVERY.City FROM US_DELIVERY WHERE (((US_DELIVERY.State)=\'' + state + '\'));', connection)) { command.CommandType = CommandType.Text; connection.Open(); List<AjaxControlToolkit.CascadingDropDownNameValue> cities = new List<AjaxControlToolkit.CascadingDropDownNameValue>(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { cities.Add(new AjaxControlToolkit.CascadingDropDownNameValue((string)reader['City'], (string)reader['City'])); } } connection.Close(); return cities.ToArray(); } } } } public static class Common { public static string AccessConnection { get { return ConfigurationManager.ConnectionStrings['CalcDB'].ConnectionString; } } } Any stupid mistakes? ... wouldn't be the first time /emoticons/smile.gif Cheers, Mark (Kristensen)
Oh man, I assumed your Object data source was for SQL Server... I have never done Ole web services to Access. I'd suggest the Google Microsoft search engine, dig up as much as you can on this topic: http://www.google.com/microsoft.html Hope you get it working bro.
First thing is to make sure the ControlToolkit is properly handled. 1) Make sure the current DLLs are in your apps /bin/ folder. I blogged about those recently: http://blogcastrepository.com/blogs/wisemx/archive/2007/02/07/ajaxtoolkit-debug-or-release-mode.aspx 2) Let's add a custom section to your web.config like this: (Within <pages><controls>) <add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" /> 3) Now on the page that uses the ControlToolkit prefix your toolkit controls with: <ajaxToolkit: Which is now referenced in your web.config. ...Try your page again, if it still doesn't work let's go over your code.