js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
来源:互联网 发布:java函数调用数组 编辑:程序博客网 时间:2024/05/17 20:31
在做 BS架构的项目时,经常遇到 需要用js 来调用 asp.net 服务器端控件的值。
大多数的 控件他的值都可以通过js调用它的 value属性来获得此控件的值,但是也有例外的情况。
经常用的 Label控件。他的值用js就不能通过value属性来获得。
Label控件 js获取的实例, var text= document.getElementById('Label1').innerText;
假如, 这样 var text= document.getElementById('Label1').value; 则 text 为Undefined。
而 TextBox 的值
就可以 var text= document.getElementById('TextBox 1').value;
对于,RadioButtonList 与 DropDownList 他们的获取方式是大不一样的! 这主要是因为 他们所生成的 html元素不一样。
DropDownList 的值 获取 比较简单:
var ddlvalue = document.getElementById('ctl00_Contentplaceholder3_ddlFolws').value;
var ddl = document.getElementById( "manufacturer") var index = ddl.seletedIndex; var Value = ddl.options[index].value; var Text = ddl.options[index].text;
而 RadioButtonList 的值获取 就比较麻烦:
var value = "";
var Result = document.getElementsByName('ctl00$Contentplaceholder3$rblResult');
for (var i = 0; i < Result.length; i++) {
if (Result.item(i).checked) {
value = Result.item(i).value;
}
}
如果 RadioButtonList 控件 没有一个选择的 那么 value的值 为空!
对于其他控件 js获取值的方法 以后在讨论。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lingxyd_0/archive/2009/05/21/4206449.aspx
- js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
- js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
- js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
- js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
- js获取asp.net服务器端控件Label,TextBox,RadioButtonList,DropDownList的值
- js获取asp.net服务器端控件Label,TextBox,RadioButtonList,DropDownList的值
- js获取asp.net服务器端控件Label,TextBox,RadioButtonList,DropD
- jquery获取ASP.NET服务器端控件dropdownlist和radiobuttonlist
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- ASP.NET中JS获取服务器控件radiobuttonlist和DropDownList选中值
- asp.net中的服务器端控件 textbox 设为只读属性后无法获取JS给其赋的值解决办法
- js操作DropDownList 与 RadioButtonList
- DropDownList控件 与TextBox控件的组合
- js无法获取只读属性服务器端控件TextBox的值
- JS获取Asp.Net服务器端控件ID
- 在asp.net中如何获取asp:DataList中子控件asp:RadioButtonList的值
- dropdownList与TextBox结合(.Net控件开发学习第一步)
- asp.net中的服务器端控件 textbox 设为只读属性后无法获取 javascript给其赋的值
- 第二章之“插入排序”
- JPA批注参考文档
- 给在校学生的一些建议-每天存一块钱
- 2011总结
- DateTimePicker控件进行时间选择与显示
- js 获取 asp.net 服务器端控件 Label 与 TextBox RadioButtonList 与 DropDownList 的值
- Android SDK 2.1 - Dev Guide - Best Practives - Designing for Performance - 中文/Chinese
- 关于圣诞节礼物的反思
- Android SDK 2.1 - Dev Guide - Best Practives - UI Guidelines - Icon Design - 中文/Chinese
- TOMCAT源码分析(启动框架)
- codeigniter中控制器(controller)的使用
- ASIHTTPRequest中HTTP请求终结者详解
- Android SDK 2.1 - Dev Guide - Best Practives - UI Guidelines - Menu Design - 中文/Chinese
- setTimeout和setInterval的使用