如何将其他参数传递给CascadingDropDown ServiceMethod?

时间:2010-10-01 10:07:52

标签: asp.net web-services cascadingdropdown

我有两个链式CascadingDropDowns。两者都很好。 问题是,在为DropDwonList提供值的基础Web方法中,我需要读取一个额外的参数。设置下拉列表的默认项目需要此参数。

我不知道如何传递该参数或阅读它。 我在网上看过ContextKey财产。但我不知道如何从WebMethod访问它。

我试图通过HttpContext.Current.Session进入会话(希望我可以从会话中提取一些参数)但是它会导致WebPage和{{1}的会话不同}。

所以我迷失在这里,有什么想法吗?

3 个答案:

答案 0 :(得分:1)

您需要三件事来让ContextKey工作。

  1. 将CascadingDropDown上的 UseContextKey 属性设置为true
  2. 更改webmethod的方法签名以接受contextKey参数:
  3. public CascadingDropDownNameValue[] GetDropDownContents( string knownCategoryValues, string category, string contextKey) { ... }

    注意:参数必须是精确套管。

    1. 使用JavaScript设置ContextKey。 AJAX CascadingDropDown在DOM中公开此属性的getter / setter:

      document.getElementById('idOfCDDL').set_contextKey('valueyouwant');

    2. HTH。

答案 1 :(得分:0)

在.cs文件中写:

cascadingdropdown1.contextKey=<parameter you need>

然后在网络方法中使用contextKey

答案 2 :(得分:0)

传递其他参数 有时,为组合框提供JSON的action方法可能需要额外的参数。以下是如何将它们传递给您的操作: CopyPassing操作方法的其他参数

function onComboBoxDataBinding(e) {
    e.data = $.extend({}, e.data, { customParam: "customValue"});
}
相关问题