残疾人的DropDownList不保留在回发选定值

编程入门 行业动态 更新时间:2024-10-26 14:33:58
本文介绍了残疾人的DropDownList不保留在回发选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我得到一个怪异的行为有一个DropDownList,当我触发回发。

I'm getting a weird behavior with a dropdownlist when I trigger a postback.

如果DropDownList中被启用,所选值保持在回发后相同。

If the dropdownlist is enabled, the selected value remains the same after a postback.

然而,如果DropDownList的被禁止(经由当用户蜱一个复选框一个JavaScript),则所选择的值复位为在列表中的第一项。

However, if the dropdownlist is disabled (via a javascript when user ticks a checkbox), then the selected value is reset to the first item in the list.

怎么来的?

推荐答案

您需要手动查找值(可能其存储在另一场左右),然后自己将其设置在code后面。这是因为如果一个控制禁用,该值将不会被调回断绝。

you need to look up the value manually (probably store it in another field or so), and then set it yourself in the code behind. This is because if a control is disabled, the value would not be posted back to the sever.

看看这个问题,并通过帕文指的是第一个答案

Check out this question, and refer to the first answer by Pavan

how在C#以获取所选残疾人下拉值

how to get selected value of Disabled dropdown in c#

如果你想在读第二个下拉列表中的值(一个失效)  服务器,你将永远无法读取更新后的值,数据监守  在禁用的控件将不会从客户端回发到服务器

If you are trying to read the value of 2nd dropdown (disabled one) at server, you will never be able to read the updated value, becuase data in disabled controls will not be posted back to server from client

更多推荐

残疾人的DropDownList不保留在回发选定值

本文发布于:2023-10-12 21:11:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485908.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:残疾人   DropDownList

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!