Category required when I do not have anything to pass.

Last post 08-21-2008 10:19 PM by vgiambattista. 2 replies.

Sort Posts:

  • Category required when I do not have anything to pass.

    07-27-2008, 11:09 PM
    • Member
      706 point Member
    • macupryk
    • Member since 06-21-2003, 3:55 AM
    • CANADA
    • Posts 322

    AjaxControlToolkit.CascadingDropDown missing required Category property value for cddMonth.
    Parameter name: Category

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: AjaxControlToolkit.CascadingDropDown missing required Category property value for cddMonth.
    Parameter name: Category
    i don't have anything to pass as a category.

    [WebMethod(Description = "Populate a month list.")]

    [System.Web.Script.Services.ScriptMethod]

    public AjaxControlToolkit.CascadingDropDownNameValue[] GetMonthList(string knownCategoryValues, string category)

    {

    List<CascadingDropDownNameValue> monthList = new List<CascadingDropDownNameValue>();

     

     

    monthList.Add(
    new CascadingDropDownNameValue("January", "1"));

    monthList.Add(new CascadingDropDownNameValue("February", "2"));

    monthList.Add(new CascadingDropDownNameValue("March", "3"));

    monthList.Add(new CascadingDropDownNameValue("April", "4"));

    monthList.Add(new CascadingDropDownNameValue("May", "5"));

    monthList.Add(new CascadingDropDownNameValue("June", "6"));

    monthList.Add(new CascadingDropDownNameValue("July", "7"));

    monthList.Add(new CascadingDropDownNameValue("August", "8"));

    monthList.Add(new CascadingDropDownNameValue("September", "9"));

    monthList.Add(new CascadingDropDownNameValue("October", "10"));

    monthList.Add(new CascadingDropDownNameValue("November", "11"));

    monthList.Add(new CascadingDropDownNameValue("December", "12"));

    return monthList.ToArray();

    }

    <ajaxToolkit:CascadingDropDown ID="cddMonth" runat="server" Category=""

    TargetControlId="ddlMonth"

    LoadingText="[Loading Months...]"

    ServicePath="../LocationService.asmx"

    ServiceMethod="GetMonthList" Enabled="True" />

     

    what should i do?

    Thank you!
  • Re: Category required when I do not have anything to pass.

    08-21-2008, 8:40 PM
    • Participant
      1,708 point Participant
    • mvang
    • Member since 12-27-2007, 6:59 PM
    • Mid West
    • Posts 361

    Taken from this site: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx 

    At runtime, the extender will make callbacks to a web service we specify (which is decorated with the System.Web.Script.Services.ScriptService attribute). In that web service, it expects a WebMethod with the following signature (note that parameter names must match too!):
    [WebMethod]
    public CascadingDropDownNameValue[] GetColorsForModel(
    string knownCategoryValues,
    string category)
    The knownCategoryValues parameter will return a string containing the currently selected category values, as well as the category to retrieve values for. For example, if the extender is populating the "Color" field, you will be passed the values for the "Make" and "Model" fields, as well as "Color" to specify the field to return values for.

    The CascadingDropDown class has a helper method for unpacking the category values: StringDictionary kv = CascadingDropDown
    .ParseKnownCategoryValuesString(knownCategoryValues);

    This method will return a StringDictionary containing the name/value pairs of the currently selected values. So imagine you've got a database with tables for the Make (manufacturer), Model, and Color information, and you're accessing that database through a DataSet to which you've added methods for getting each set of values.

    "If you have knowledge, let others light their candles in it."
    — Margaret Fuller
  • Re: Category required when I do not have anything to pass.

    08-21-2008, 10:19 PM
    Answer

    mac,

    Just put something, "text" would do, as the Category property value in your Cascading drop down extender.  This is just to make your call match the signature of your web service.  You don't have to actually use the value you are passing in your implementation.

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
Page 1 of 1 (3 items)