一个简单的.net 给ListBox 添加双击事件的例子,希望能帮助需要的人
.aspx 页面代码:
<form id="form1" runat="server">
<asp:ListBox ID="ListBox1" SelectionMode="Multiple" runat="server" Width="83px">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:ListBox>
<asp:ListBox ID="ListBox2" runat="server" Width="83px">
</asp:ListBox>
<input id="Dbclickflag" type="hidden" value="false" name="Dbclickflag" runat="server">
<script language="vbscript">
option explicit
sub ListBox1_ondblclick()
Form1.Dbclickflag.value="true"
Form1.submit()
end sub
</script>
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:ListBox>
<asp:ListBox ID="ListBox2" runat="server" Width="83px">
</asp:ListBox>
<input id="Dbclickflag" type="hidden" value="false" name="Dbclickflag" runat="server">
<script language="vbscript">
option explicit
sub ListBox1_ondblclick()
Form1.Dbclickflag.value="true"
Form1.submit()
end sub
</script>
</form1>
.aspx.cs 页面
if (IsPostBack)
{
if (Dbclickflag.Value == "true")
{
{
if (Dbclickflag.Value == "true")
{
Dbclickflag.Value =""; //清空设定的值
。
。
。 //此处写 双击后要实现的操作就可以
}
}
}
转载于:https://blog.51cto.com/smilecong/148242