0

I have two chained CascadingDropDowns. Both are working fine. The thing is that in the underlying web methods which are supplying values for DropDwonList I need read one additional parameter. This parameter is needed for setting up the default item for dropdownlist.

I do not know how to pass that parameter or read it. I've read on the Internet about the ContextKey property. But I do not know how to acces it from the WebMethod.

I've tried to get to the session through HttpContext.Current.Session (hoping that I could extract some parameter from the session) but it seams that the Session is different for the WebPage and WebMethod.

So I am lost here, any ideas?

4

3 回答 3

1

您需要三件事才能使 ContextKey 工作。

  1. 将CascadingDropDown 上的UseContextKey属性设置为 true
  2. 更改 webmethod 的方法签名以接受 contextKey 参数:

public CascadingDropDownNameValue[] GetDropDownContents( string knownCategoryValues, string category, string contextKey) { ... }

注意:参数必须是精确的大小写。

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

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

HTH。

于 2010-10-01T12:30:00.547 回答
0

在您的 .cs 文件中写入:

cascadingdropdown1.contextKey=<parameter you need>

然后在网络方法中使用contextKey

于 2012-03-26T12:10:17.427 回答
0

传递附加参数 有时,为组合框提供 JSON 的操作方法可能需要附加参数。以下是将它们传递给您的操作的方法: CopyPassing additional arguments to the action method

function onComboBoxDataBinding(e) {
    e.data = $.extend({}, e.data, { customParam: "customValue"});
}
于 2012-10-11T08:06:47.820 回答