我有两个链式CascadingDropDowns
。两者都很好。
问题是,在为DropDwonList
提供值的基础Web方法中,我需要读取一个额外的参数。设置下拉列表的默认项目需要此参数。
我不知道如何传递该参数或阅读它。
我在网上看过ContextKey
财产。但我不知道如何从WebMethod
访问它。
我试图通过HttpContext.Current.Session
进入会话(希望我可以从会话中提取一些参数)但是它会导致WebPage
和{{1}的会话不同}。
所以我迷失在这里,有什么想法吗?
答案 0 :(得分:1)
您需要三件事来让ContextKey工作。
public CascadingDropDownNameValue[] GetDropDownContents(
string knownCategoryValues, string category, string contextKey) { ... }
注意:参数必须是精确套管。
使用JavaScript设置ContextKey。 AJAX CascadingDropDown在DOM中公开此属性的getter / setter:
document.getElementById('idOfCDDL').set_contextKey('valueyouwant');
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"});
}