通过javascript设置下拉值,而不在后面添加代码 [英] Drop down value set through javascript, not getting in code behind
本文介绍了通过javascript设置下拉值,而不在后面添加代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过javascript根据另一个下拉菜单的值设置一个下拉菜单的选定项目.
但是我没有在代码中得到这个选中的项目值.
最后,我使用隐藏字段"来设置下拉值,然后在后面的代码中使用此隐藏字段值.
任何人都可以向我解释这种行为吗?
java脚本代码:-
I am setting selected item of one drop down according to the value of other drop down through javascript.
But I am not getting this selected item value in code behind.
Finally I used Hidden Field for setting the drop down value and then used this hidden field value in code behind.
Can any one explain me this behavior?
java-script code : -
for (var j = 0; j < ddlDataType.options.length; j++)
{
if(ddlDataType.options[j].text.toLowerCase() ==
auditTableColumnsArray[i][0].toString().toLowerCase())
{
ddlDataType.options[j].selected = true;
$get("<%= hfDataType.ClientID %>").value = ddlDataType.options[j].value;
break;
}
}
推荐答案
get(" ).value = ddlDataType.options [j] .value; break ; } }
get("<%= hfDataType.ClientID %>").value = ddlDataType.options[j].value; break; } }
您是否已启用下拉菜单的视图状态?
如果未为控件设置"EnableViewState = true".
Have you enabled view state of the dropdown?
if not set "EnableViewState=true" for the control.
我认为您在页面加载中具有ur fill下拉方法,而不是!ispostback,请对其进行一次检查
I think u have ur fill drop down method in page load, instead of !ispostback, check it once
这篇关于通过javascript设置下拉值,而不在后面添加代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文