访问由代码隐藏中的查询填充的下拉列表的选定值
我有一组用 JQuery ajax 填充的级联下拉菜单。 然而,当用户按下提交(在表单其余部分的末尾)时,我需要发回并获取下拉列表的值。因为它们已经填充了客户端 ASP.NET FREAKS OUT。
它告诉我使 EnableEventValidation="false"
所以我这样做了,但它仍然没有得到正确的值。它仅获取已使用后面的代码绑定的值。
有谁知道如何访问在隐藏代码之外创建的下拉列表(或任何输入)的值?
I've got a set of cascading drop downs that populate with JQuery ajax.
However when the user presses submit (at the end of the rest of the form) i need to post back and get the values of the drop downs. since they have been populated client side ASP.NET FREAKS OUT.
It tells me to make EnableEventValidation="false"
So i do that but it still doesn't get the correct value. It only gets a value that has been bound using the code behind.
Does anybody know how to access values of drop downs (or any input) that have been created outside of the code behind?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 Request.Form 或 Request.Params 集合直接读取 POST 值。我认为这绕过了 ASP.NET 所做的检查。
Try to read the POST value directly using the Request.Form or Request.Params collections. I think this circumvents the checking that ASP.NET does.
我之前使用过一个简单的解决方案。
当您使用客户端代码填充下拉列表时,服务器会崩溃,因为下拉列表不应该添加新数据。
只需在页面中的某个位置放置一个隐藏文本框,在将值添加到下拉列表时将值添加到其中,然后在服务器端拆分字符串以获取值并以编程方式将它们添加到下拉列表中。
there is a simple solution to this that i used earlier.
when you populate the dropdowns using clientside code the server freaks out because dropdowns arnt supposed to be adding new data.
simply put a hidden textbox somewhere in the page add the values to it when ur adding them to the dropdowns then split the string on the server side to get the values and add them programatically to the dropdowns.