asp.net button_click函数为devexpress ASPxHiddenField返回奇怪的值
本文关键字:返回 ASPxHiddenField devexpress button net click 函数 asp | 更新日期: 2023-09-27 18:14:10
我的页面中有一个隐藏字段:
<dx:ASPxHiddenField ID="screenWidth" runat="server" ClientIDMode="Static"
ClientInstanceName="screenWidth"></dx:ASPxHiddenField>
和我设置它的值使用JQuery:
$(document).ready(function(){
$("#screenWidth").val($(window).width());
var value = document.getElementById('screenWidth').value;
alert(value);
});
(最后两行用于调试,警报显示正确的值)。
在同一页面上,我有一个按钮,用于根据窗口大小调整其中一个控件的大小,我正试图获得屏幕大小:
string screenWidth = Request.Form["screenHeight"].ToString();
但是,当我点击按钮时,我得到了这个screenwidth变量:
{"data":"12|#|#"}
请求。Form["screenHeight"]返回与上面相同的字符串。
似乎Devexpress框架有一个可疑的方式(好吧,对我来说是可疑的)来处理他们的隐藏字段:我必须将窗口值设置为隐藏字段的新属性:
$(document).ready(function(){
screenWidth.Set('scW', $(window).width());
alert(screenWidth.Get('scW'));
});
然后,在c# button_click函数中,我这样得到值:
string screenWidth1 = screenWidth["scW"].ToString();
这个链接有帮助:如何从ASPxHiddenField中获取一个键值
引自文章:
" ASPxHiddenField组件代表一个字典,它可以保持无限数量的元素。"
正如天王星所建议的,这是在他们的文档中声明的:ASPxHiddenField类