1

I want to add a double click event to my Listbox in asp.net

But the only events on a listbox in ASP.net seem to be those:

enter image description here

Is there a way I could add a DoubleClick event without javascript?

Any help would be appreciated

0

1 Answer 1

3

No, I'm afraid not! You can call __doPostBack yourself in a js-function from ondblclick.

<script type="text/javascript">
 <!--
     function ListBox1_DoubleClick() {
         __doPostBack('<%= ListBox1.ClientID  %>', 'doubleclick');
     }
 -->
 </script>

<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>

codebehind:

public void Page_Load(object sender, EventArgs e)
{
  string parameter = Request["__EVENTARGUMENT"]; // parameter
  // Request["__EVENTTARGET"]; // btnSave
}
Sign up to request clarification or add additional context in comments.

1 Comment

+1. Thanks to Javascript you can implement the un-implemented

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.