无为清净楼资源网 Design By www.qnjia.com
如果要想给 DropDownList 服务器控件添加客户端下拉事件,我们可以强制给它添加 onchange 事件,尽管在控件中没有这个方法的提示。添加完这个事件还不能达到目的,还要设置 AutoPostBack 属性为 false,不让它回发后台事件。
以下就是为大家分享的代码:
<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>DropDownList添加客户端下拉事件</title> <script type="text/javascript"> function getDropDownList() { var ddl1 = document.getElementById("<%=ddl1.ClientID%>"); var text = ddl1.options[ddl1.options.selectedIndex].text; //获取text值 var value = ddl1.value; //获取value值 alert("Text:" + ddl1.options[ddl1.options.selectedIndex].text + ", Value:" + ddl1.value); } </script> </head> <body> <form id="form1" runat="server"> <asp:DropDownList ID="ddl1" runat="server" AutoPostBack="false" onchange="getDropDownList();"> <asp:ListItem Text="T1" Value="V1" Selected="True"></asp:ListItem> <asp:ListItem Text="T2" Value="V2"></asp:ListItem> <asp:ListItem Text="T3" Value="V3"></asp:ListItem> </asp:DropDownList> </form> </body> </html>
总结一下,也就是说,要想给DropDownList下拉框添加客户端下拉事件,必须做两步工作,一是添加强制onchange事件,二是把 AutoPostBack属性设为false,就是这么简单!
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年09月27日
2024年09月27日
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 金佩姗.1997-喜新恋旧【现代派】【WAV+CUE】
- 梁静茹.2007-崇拜【相信音乐】【WAV+CUE】
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《云水禅心 - 佛曲古筝礼赞1-2》1CD[MP3][190MB]
- 纯音入心系列纯音乐《精心传神-古筝》1CD[MP3][363.1MB]
- 纯音入心系列纯音乐《琴瑟古风之古筝精选曲》1CD[MP3][354.1MB]
- 陈晓东.1997-在乎你感受(EP)【宝丽金】【WAV+CUE】
- 黄凯芹.1990-给你留念(2024环球MQA-UHQCD限量版)【环球】【WAV+CUE】
- 张学友.1999-有个人【宝丽金】【WAV+CUE】
- 纯音入心系列纯音乐《古筝佛曲》1CD[MP3][411.1MB]
- 纯音入心系列纯音乐《古筝世界名曲》1CD[MP3][38.9MB]
- 纯音入心系列纯音乐《古筝新奏-菩提妙音》1CD[MP3][112.3MB]
- 陈思安.1993-怀念福建金曲5CD【歌丽美】【WAV+CUE】
- 张学友.1999-有个人【宝丽金】【WAV+CUE】