[英]asp.net reading client side dropdown values in codebehind
So I have two dropdown controls, the second one (the data comes from a JSON file) is filled depending on the value of the first dropdown: 所以我有两个下拉控件,第二个(数据来自JSON文件)根据第一个下拉列表的值填充:
<asp:DropDownList runat="server" ID="task1DD"/>
<asp:DropDownList runat="server" ID="task2DD"/>
In the code behind I used an override render method to accept the client's data: 在后面的代码中,我使用了重写渲染方法来接受客户端的数据:
protected override void Render(HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation(task2DD.UniqueID,"text_from_dd");
ClientScript.RegisterForEventValidation(task2DD.UniqueID,"text_from_dd");
...
base.Render(writer);
}
Now when I tried to read the value from the second Dropdown: 现在,当我尝试从第二个Dropdown中读取值时:
task2DD.Text
I don't get nothing, like the variable is empty. 我什么也没得到,就像变量为空。 Are there other steps that I need to do in order to read the data that was filled in the client? 为了读取客户端中填充的数据,我还需要执行其他步骤吗?
Use the following to get the display text of what is selected 使用以下命令获取所选内容的显示文本
task2DD.SelectedItem.Text;
and the following to get the value 和以下获得价值
task2DD.SelectedValue;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.