Click here to Skip to main content
15,886,024 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use double click event in ASP.NET. I already used this code but it didn't worked for me.
Please help me.

C#
protected void Page_Load(object sender, EventArgs e)
    {
          if (!IsPostBack)
            {
               try
        {
              String postBackReferenceForListBox =

                this.Page.GetPostBackClientEvent(btnForListBoxDoubleClick, "dblClickfromHiddenButton");

                ListBox1.Attributes.Add("ondblclick", postBackReferenceForListBox);
            }
        catch (Exception ex)
        { }
    }

}
    private void btnForListBoxDoubleClick_ServerClick(object sender, System.EventArgs e)
    {
        try
        {
            string argument = Request.Params["__EVENTARGUMENT"].Trim();

            if (argument == "dblClickfromHiddenButton")
            {
                Response.Write("HI");
                // logic to process the selected item from listbox goes here
            }
        }
        catch (Exception ex)
        { }

    }
Posted
Updated 7-Mar-11 17:40pm
v2
Comments
Albin Abel 7-Mar-11 23:22pm    
Avoid using capital letters. It means shouting here

1 solution

This[^] would help you. It uses ListBox1.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBox1, "move"));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900