来自JavaScript问题的ASP dropdownlist动态值 [英] asp dropdownlist dynamic value from javascript issue
问题描述
我有一个包含5个项目的下拉列表。最后一项的值为其他。通过选择其他,出现带有输入的弹出窗口。我通过javascript将此输入的值设置为此项目。因此,请珍惜插入的文字。当我提交表单时,此动态值不起作用,但是select的其他项起作用。有任何想法吗?非常感谢!
I have a dropdownlist with 5 items. Value of last item is "other". By choosing "other" appears popup with input. The value of this input i set to this item by javascript. So value becoms inserted text. When i submitting the form, it doesn't work with this dynamic value, but other items of select works. Any ideas? Thanks very much!
推荐答案
您可以使用hiden字段
Rather than set this value as droupdown list item value, you can use hiden field
<input type="hidden" id="hiddenField" runat="server" />
使用如下所示的JavaScript设置值
set value using JavaScript as below
document.getElementById ("hiddenField").value = "inputValue";
hiddenField值可以从下面的代码中访问
hiddenField value can access from code behind as below
string inputValue = hiddenField.Value;
这篇关于来自JavaScript问题的ASP dropdownlist动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!