ASP.NET中ListBox实现Double Click事件
来源:互联网 发布:c语言中!x是什么意思 编辑:程序博客网 时间:2024/05/17 03:09
(1)在WEB页面上加入JS脚本和存放ListBox事件的隐藏输入框,LISTBOX是用来保存时间的名称,在CS页面用到:其JS代码如下:
<script language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so that inpage load event we can identify event.
*/
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
</script>
(2)将ASP.NET控件LISTBOX中加入双击事件声明如下:
<asp:ListBox id="ListBox1"
ondblclick="ListBox1_DoubleClick()" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
<asp:ListItem Value="4">Four</asp:ListItem>
</asp:ListBox>
(3)在WEB窗体加载的时候执行如下代码(即双击LISTBOX中ITEM后执行的内容),
if(Request.Params["ListBox1Hidden"] != null
&& (string)Request.Params["ListBox1Hidden"] == "doubleclicked" )
{
//the Listwas double click Event
}
}
例子如下:
<html>
<head>
<script language="javascript">
function ListBox1_DoubleClick() {
/* we will change value of this hidden field so
that in
page load event we can identify event.
*/
document.forms[0].ListBox1Hidden.value = "doubleclicked";
document.forms[0].submit();
}
</script>
</head>
<body>
<form runat="server">
<div>Double click on Listbox
<br />
<asp:ListBox id="ListBox1"
ondblclick="ListBox1_DoubleClick()" runat="server">
<asp:ListItem Value="1">One</asp:ListItem>
<asp:ListItem Value="2">Two</asp:ListItem>
<asp:ListItem Value="3">Three</asp:ListItem>
<asp:ListItem Value="4">Four</asp:ListItem>
</asp:ListBox>
<input type="hidden" name="ListBox1Hidden" />
</div>
<div>click on button
<br />
<asp:Button id="Button1" onclick="Button1_Click"
runat="server" Text="Button"/>
</div>
</form>
</body>
</html>WEB窗体加载时候执行下列代码就能实现双击ListBox中Item执行一些操作void Page_Load(Object sender, EventArgs e){
if(Request.Params["ListBox1Hidden"] != null
&& (string)Request.Params["ListBox1Hidden"] == "doubleclicked") {
//This means It was double click
Response.Write("Double Click was fired selected item is "
+ ListBox1.SelectedItem.Text);
- ASP.NET中ListBox实现Double Click事件
- ASP.NET中ListBox实现Double Click事件
- ASP.NET中ListBox实现Double Click事件
- asp.net中onclientclick事件与服务器事件click
- 在Android中,如何通过onTouchEvent实现Double Click,判断为双击事件
- Asp.NET 中两个listbox实现值相互传递
- asp.net ListBox控件添加双击事件
- asp.net如何实现按回车键就执行按钮的Click()事件的办法
- Jquery实现双击行的同时不单计行(在Javascript中让单击Click和Double Click双击事件各自独立)
- Javascript中让单击Click和Double Click双击事件各自独立
- 在ASP.NET页面中,按回车键就执行相应按钮的Click()事件
- ASP.net中使用ListBox一点经验
- asp.net 中listbox 中的项删除
- Asp.net 中listbox 滚动条定位
- Asp.net中ListBox的用法!
- Asp.net中ListBox的用法!
- asp.net c# 动态添加按钮Click事件
- asp.net 控件按回车执行click事件
- 在 Y450A上 安装定制的FreeBSD7.2
- 解决linux下不能删除乱码文件的笨方法
- 8个DBA最常用的监控Oracle数据库的常用shell脚本
- 页面设置、打印预览、打印
- linux定时任务--crontab的用法
- ASP.NET中ListBox实现Double Click事件
- ping命令实现内幕
- JAVA实现FTP文件上传下载文件
- 在ASP.Net4.0中使用QueryExtender控件创建高效的搜索页面
- 修改主机名
- 大家好!!!
- VS 2008 "website" 项目转化为 "web application" 项目
- 完成端口模型学习
- 宏定义