由javascript修改的HiddenField值不会回发 [英] HiddenField value modified by javascript is not posted back

查看:68
本文介绍了由javascript修改的HiddenField值不会回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很奇怪,但我一直在我的代码中使用这种方法:我有下拉列表,我使用回调填充客户端,因此我无法从代码后面访问他们选择的值使用隐藏字段在其中存储选定的值。我在回发时检索隐藏字段的值没有问题,但突然它停止工作并且总是空白,即使客户端的值存在也是如此。
有什么想法吗?

This is weird, but I've been using this method all over my code: I have dropdown lists that I populate client-side, using callbacks and because of this I'm unable to access their selected values from code behind and using a hidden field to store selected value in it. I had no problem retrieving the hidden field's value on postback, but all of a sudden it stopped working and is always blank, even when the value on client side is present. Any thoughts?

P.S。我没有在回发时设置或重置隐藏字段。

P.S. I'm not setting or resetting hidden fields on postback.

推荐答案

好吧,如果有人想知道什么是错的:似乎有相关的东西到jQuery。
问题是,DropDownLists和隐藏字段以及导致回发的按钮位于jQuery UI对话框中,该对话框在页面加载时启动而不打开并附加到表单。除了这个对话框,我初始化另一个并且还附加到表单,但由于某种原因,第一个附加对话框在回发工作时表现出奇怪的行为,但隐藏字段不保留该值。如果我没有将第二个对话框附加到表单,一切都按预期工作。无法真正告诉第二个对话框可能会附加什么导致这种奇怪的行为。

Okay, if someone wonders what's wrong: it seems there's something related to jQuery. The thing is that DropDownLists and the hidden field, along with the button that causes postback are inside a jQuery UI dialog that is initiated on page load without opening and appended to the form. Besides this dialog i'm initializin another one and also appending to the form, but for some reason the first appended dialog exibits the weird behavior when postback works, but hidden field does not retain the value. If i don't append the second dialog to the form, everything works as expected. Can't really tell what might appending the second dialog be doing that is causing this weird behavior.

PS如果我颠倒了这两个对话框的附加顺序,它工作得很好......很奇怪!

P.S if i reverse the order in which those two dialog boxes are appended, it works just fine... Weird!

这篇关于由javascript修改的HiddenField值不会回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆