locked
CascadingDropDown generates contextKey missing error RRS feed

  • Question

  • User2044545287 posted

    I have three cascading drop downs on an ASP.NET 2.0 aspx page. I do not have UseContextKey or ContextKey attributes set, but for

    whatever reason my first cascadingdropdown never fills, instead the only entry is [Method error 500] . When I examine the http response

    using web development helper I see the following message

    "Invalid web service call, missing value for parameter: \u0027contextKey\u0027."

     Why the hell is the toolkit looking for a ContextKey even though the ContextKey and UseContextKey attributes are not defined? You'll notice

    that in the cascadingdropdown example in the samplewebsite that whenever ContextKey and UseContextKey are not defined there is no need to

    specify ContextKey in the parameter list for the dropdown webservice method.

    PLEASE HELP!!!! Here is the pertinent code - (the webservice code behind follows the aspx script -- the functions for the dropdowns are overloaded with a function that

    has ContextKey in its parameter list, and one that doesn't)

    <asp:DropDownList ID="ddlService" runat="server" />

    <ajaxToolkit:CascadingDropDown ID="CascadingDropDownService"

    runat="server"

    TargetControlID="ddlService"

    Category="Service"

    PromptText="Select A Service"

    ServiceMethod="GetServices"

    ServicePath="ServiceClassRank.asmx"

    />

    <ajaxToolkit:ValidatorCalloutExtender runat="Server"

    ID="ValidatorCalloutExtenderService"

    TargetControlID="RFVService"

    HighlightCssClass="validatorCalloutHighlight" />

    <asp:RequiredFieldValidator runat="server"

    ID="RFVService"

    ControlToValidate="ddlService"

    Display="None"

    ErrorMessage="Service is required." />

    </td>

    <td class="tblRowMainCss">

    *Class&nbsp;&nbsp;

    <asp:DropDownList ID="ddlClass"

    runat="server"

    AutoPostBack="True"

    OnSelectedIndexChanged="ddlClass_SelectedIndexChanged"/>

    <ajaxToolkit:CascadingDropDown ID="CascadingDropDownClass"

    runat="server"

    Category="Class"

    PromptText="Select A Class"

    TargetControlID="ddlClass"

    ServiceMethod="GetClassesForService"

    ServicePath="ServiceClassRank.asmx"

    ParentControlID="ddlService"

    />

    <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="ValidatorCalloutExtenderClass"

    TargetControlID="RFVClass"

    HighlightCssClass="validatorCalloutHighlight" />

    <asp:RequiredFieldValidator runat="server" ID="RFVClass"

    ControlToValidate="ddlClass"

    Display="None"

    ErrorMessage="Class is required." />

    </td>

    <td class="tblRowMainCss" style="width: 323px;">

    *Rank &nbsp;&nbsp;

    <asp:DropDownList ID="ddlRank"

    runat="server"

    Enabled="false"/>

    <ajaxToolkit:CascadingDropDown ID="CascadingDropDownRank"

    runat="server"

    Category="Rank"

    PromptText="Select A Rank"

    TargetControlID="ddlRank"

    ServiceMethod="GetRanksForClassAndService"

    ServicePath="ServiceClassRank.asmx"

    ParentControlID="ddlClass"/>

     //webservice code behind

     

    [WebMethod]

    public CascadingDropDownNameValue[] GetServices(

    string knownCategoryValues,string category)

    {

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    serviceTableAdapter serviceAdapter = new serviceTableAdapter();Services.serviceDataTable serviceTable = serviceAdapter.GetServices();

     

    List<CascadingDropDownNameValue> values =

    new List<CascadingDropDownNameValue>();foreach (Services.serviceRow dr in serviceTable)

    {

    values.Add(
    new CascadingDropDownNameValue( dr.description, dr.brsv));

    }

    return values.ToArray();

    }

    [WebMethod]

    public CascadingDropDownNameValue[] GetServices(

    string knownCategoryValues,

    string category,string contextKey)

    {

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    serviceTableAdapter serviceAdapter = new serviceTableAdapter();

    Services.serviceDataTable serviceTable = serviceAdapter.GetServices();

    List<CascadingDropDownNameValue> values =

    new List<CascadingDropDownNameValue>();

    foreach (Services.serviceRow dr in serviceTable)

    {

    if (dr.brsv == contextKey)

    {

    values.Add(
    new CascadingDropDownNameValue(dr.description, dr.brsv, true));

    }

    else

    {

    values.Add(
    new CascadingDropDownNameValue(dr.description, dr.brsv));

    }

    }

     

    return values.ToArray();

    }

    [
    WebMethod]

    public CascadingDropDownNameValue[] GetClassesForService(

    string knownCategoryValues,string category)

    {

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    if (!kv.ContainsKey("Service"))

    {

    return null;

    }

    string serviceId = kv["Service"];

    classTableAdapter classAdapter = new classTableAdapter();

    Services._classDataTable classTable = classAdapter.GetClassesByServiceId(serviceId);

    List<CascadingDropDownNameValue> values =

    new List<CascadingDropDownNameValue>();foreach (Services._classRow dr in classTable)

    {

    values.Add(
    new CascadingDropDownNameValue(dr.description, dr._class ));

    }

    return values.ToArray();

    }

    [WebMethod]

    public CascadingDropDownNameValue[] GetClassesForService(

    string knownCategoryValues,

    string category,string contextKey)

    {

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    if (!kv.ContainsKey("Service"))

    {

    return null;

    }

    string serviceId = kv["Service"];

    classTableAdapter classAdapter = new classTableAdapter();

    Services._classDataTable classTable;if (contextKey == "RegisterOnline")

    {

    classTable = classAdapter.GetClassesByServiceIdNoPFPA(serviceId);

    }

    else

    {

    classTable = classAdapter.GetClassesByServiceId(serviceId);

    }

    List<CascadingDropDownNameValue> values =

    new List<CascadingDropDownNameValue>();

    foreach (Services._classRow dr in classTable)

    {

    values.Add(
    new CascadingDropDownNameValue(dr.description, dr._class));

    }

    return values.ToArray();

    }

    [
    WebMethod]

    public CascadingDropDownNameValue[] GetRanksForClassAndService(

    string knownCategoryValues,string category)

    {

    StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

    if (!kv.ContainsKey("Service"))

    {

    return null;

    }

    string serviceId = kv["Service"];if (!kv.ContainsKey("Class"))

    {

    return null;

    }

    string classId = kv["Class"];

    rankTableAdapter rankAdapter = new rankTableAdapter();

     

    Services.rankDataTable rankTable = rankAdapter.GetRanksByClassIdAndServiceId(classId, serviceId);

    List<CascadingDropDownNameValue> values =

    new List<CascadingDropDownNameValue>();foreach (Services.rankRow dr in rankTable)

    {

    //rankcode + ' - ' + rankname

    values.Add(new CascadingDropDownNameValue(dr.rankcode + '-' + dr.rankname, dr.rankcode));

    }

    return values.ToArray();

    }

     

     

     

     

    Thursday, October 9, 2008 10:16 AM

All replies

  • User1096927315 posted

     Avoid using web- or scriptmethods with the same name, so if you want to overload a method with one with an extra parameter (even if it's contextKey), use another name.

    Monday, December 29, 2008 9:09 AM
  • User-1748834005 posted

    You have to leave that parameter out.  I'm using version 17.1.1.0 and I had to leave that parameter out in order for it to work.  I also had to name the prefixText and count parameters exactly the same because I was getting an internal server error for some reason when I tried using my own parameter names.

    Thursday, December 7, 2017 9:50 PM