.net服务器控件转换为html控件
来源:互联网 发布:什么软件买股票 编辑:程序博客网 时间:2024/06/05 16:32
1. DropDownList
<asp:DropDownList runat="server" ID="ddlTest" >
<asp:ListItem Value="Items" Text="Items11" ></asp:ListItem>
<asp:ListItem Value="Items2" Text="Items12"></asp:ListItem>
<asp:ListItem Value="Items3" Text="Items13" Selected="True" ></asp:ListItem>
<asp:ListItem Value="Items33" Text="Items4" ></asp:ListItem>
<asp:ListItem Value="Items4" Text="Items5" ></asp:ListItem>
</asp:DropDownList>
转换成:
<select name="ddlTest" id="ddlTest">
<option value="Items">Items11</option>
<option value="Items2">Items12</option>
<option selected="elected" value="Items3">Items13</option>
<option value="Items33">Items4</option>
<option value="Items4">Items5</option>
</select>
用JS操作html:
function OperaDDl()
{
var obj=document.getElementById("ddlTest");
///得到当前选中的值
var currentSelectedValue=obj[obj.selectedIndex].value 或者 obj[obj.selectedIndex].innerText; 或者 obj.options.value 或者 obj.options[obj.selectedIndex].value/text
//设置显示那个值
obj.selectedIndex=integer;
//增加项
obj.options.add(new Option("Value","Text"));
//删除项
obj.options[i].remove();
}
2. RadioButtonList
根据RepeatLayout转换成Table和Span. RepeatDirection的不同是在一行很是多行
<asp:RadioButtonList runat="server" ID="rbiTest">
<asp:ListItem Value="value1" Text="Text1"></asp:ListItem>
<asp:ListItem Value="value1" Text="Text2"></asp:ListItem>
<asp:ListItem Value="value1" Text="Text3"></asp:ListItem>
<asp:ListItem Value="value1" Text="Text4"></asp:ListItem>
<asp:ListItem Value="value1" Text="Text5"></asp:ListItem>
</asp:RadioButtonList><br />
如果RepeatLayout没有或=“Table"
<table id="rbiTest">
<tr>
<td><input id="rbiTest_0" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_0">Text1</label></td>
</tr><tr>
<td><input id="rbiTest_1" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_1">Text2</label></td>
</tr><tr>
<td><input id="rbiTest_2" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_2">Text3</label></td>
</tr><tr>
<td><input id="rbiTest_3" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_3">Text4</label></td>
</tr><tr>
<td><input id="rbiTest_4" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_4">Text5</label></td>
</tr>
</table>
如果RepeatLayout=“Flow"
<span id="rbiTest"><input id="rbiTest_0" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_0">Text1</label><br /><input id="rbiTest_1" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_1">Text2</label><br /><input id="rbiTest_2" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_2">Text3</label><br /><input id="rbiTest_3" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_3">Text4</label><br /><input id="rbiTest_4" type="radio" name="rbiTest" value="value1" /><label for="rbiTest_4">Text5</label></span><br />
不管是转换成Table 还是Span我们发现一个重要特征,那就是被包含的子项都是type="radio"的input并且name都相同。
从而可以用js操作:
function rbiOpera()
{
var items=document.getElmentsByName("rbiId");
//循环得到选中的值
for(var i=0;i<items.length;i++)
{
if(items[i].checked)
return items[i].value;
}
}
- .net服务器控件转换为html控件
- 如何在VS2008中将HTML控件转换为服务器控件
- .net HTML 服务器控件
- HTML服务器控件与ASP.NET服务器控件的区别
- asp.net服务器控件与html服务器控件的区别
- asp.net服务器控件与html服务器控件的区别
- 【ASP.NET】——Web服务器控件、HTML服务器控件
- HTML在线编辑器--服务器控件~~.NET实现~~
- ASP.NET 服务器控件对应HTML标签
- ASP.NET 服务器控件对应HTML标签
- ASP.NET 服务器控件对应HTML标签
- ASP.Net的Web服务器控件、Html服务器控件和Html控件
- ASP.Net的Web服务器控件、Html服务器控件和Html控件
- Asp.net服务器控件和Html服务器端控件的区别
- ASP.NET 网页转换为用户控件
- HTML控件和服务器控件
- 服务器控件与HTML控件
- html,html服务器控件,asp。net服务器控件 区别,以及 onclick ,onserverclick ,onclientclick 事件....
- 经典排序算法汇总(C#)
- 【树的重心维护 动态树】资源运输
- 计算机的工作原理(基于机器指令的分析)
- PCL学习笔记一:io
- ubuntu下ssh server服务配置
- .net服务器控件转换为html控件
- 让开发者高效编程的10个新框架
- 听学术交流会有感
- dhtmlx tree的使用方式
- Eclipse使用Git代替CVS与SVN实现版本管理
- CC、CQ已可用了,你懂的
- zoj 1108 FatMouse's Speed
- Visual Studio 2010 编译 MongoDB C++ Client Driver(看这里,终于解决了编译问题,谢谢大神的分享)
- web.xml配置文件概述