如何从asp.net中的DropDownCheckBoxes控件获取文本和值.... [英] How to get the text and value from DropDownCheckBoxes control in asp.net....?
问题描述
如何从asp.net中的DropDownCheckBoxes控件获取文本和值....?
< asp:DropDownCheckBoxes ID =ddllanguagerunat =serveronchange =selectedVal()AddJQueryReference =TrueUseButtons =falseUseSelectAllNode =True>< Style SelectBoxWidth = 200DropDownBoxBoxWidth =200DropDownBoxBoxHeight =130/>
< texts selectboxcaption = - 选择 - >
因此,当我选中下拉复选框时,所选值显示一个文本框。这是我的调节,但我没有得到文字和谷。
这是我的javascript函数
How to get the text and value from DropDownCheckBoxes control in asp.net....?
<asp:DropDownCheckBoxes ID="ddllanguage" runat="server" onchange="selectedVal()" AddJQueryReference="True" UseButtons="false" UseSelectAllNode="True"><Style SelectBoxWidth="200" DropDownBoxBoxWidth="200" DropDownBoxBoxHeight="130" />
<texts selectboxcaption="-Select-">
So when i checked the dropdown checkbox that selected values show one textbox.this is my reguriment but i am not getting text and vale .
this is my javascript function
<script type="text/javascript">
function selectedVal() {
var a = document.getElementById('<%=ddllanguage.ClientID%>').value;
alert(a);
</script>
但mu输出为空我在所有情况下都使用diifernt脚本功能同样的事情会发生... [租赁给出解决方案。
问候
Ravinder
but mu output is empty i am using diifernt script function in all cases same thing will happen ...[lease give a solution .
Regards
Ravinder
推荐答案
我为你的场景推出了一个测试应用程序请看下面的例子: -
我页面中的控件:
i)'asp:DropDownCheckBoxes '控制
Ex: -
I have crested one test application for your scenario and its working great, please have a look into the below example :-
Controls in my page :
i) A 'asp:DropDownCheckBoxes' control
Ex :-
<asp:dropdowncheckboxes id="ddllanguage" xmlns:asp="#unknown">
runat="server"
onchange="onSelectionChange()"
AddJQueryReference="True"
UseButtons="false"
UseSelectAllNode="True"
ClientIDMode="Static">
<style selectboxwidth="200" dropdownboxboxwidth="200" dropdownboxboxheight="130" />
<texts selectboxcaption="Select Values" />
<items>
<asp:listitem text="Test1" value="1"></asp:listitem>
<asp:listitem text="Test2" value="2"></asp:listitem>
<asp:listitem text="Test3" value="3"></asp:listitem>
<asp:listitem text="Test4" value="4"></asp:listitem>
</items>
</asp:dropdowncheckboxes>
ii)显示所选值的文本框
Ex: -
ii) A textbox to display the selected values
Ex :-
<asp:textbox runat="server" id="txtValue" clientidmode="Static" xmlns:asp="#unknown"></asp:textbox>
现在jQuery代码将选定的复选框文本填充到文本框中作为逗号分隔值: -
Now the jQuery code to populate the selected checkbox texts into the textbox as comma separated values :-
function onSelectionChange() {
var selectedVals = '';
.each(
(' #ddllanguage input [type = checkbox] ]:选中'),功能(){
selectedVals + =
('#ddllanguage input[type=checkbox]:checked'), function () { selectedVals +=
这篇关于如何从asp.net中的DropDownCheckBoxes控件获取文本和值....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!