C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

How to Handle Double Click Event in a ASP.NET ListBox Control


Posted Date: 14 Apr 2009    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Ramesh SMember Level: Gold    
Rating: 1 out of 5Points: 7



This article describes how to handle double click event in ASP.NET List control.

Generally, you cannot handle Server side double click event in a ASP.NET List control. But it can be achieved by some workaround methods.

The following steps explain a work around solution:


1. Add a button control and hide it using styles

eg:


2. Add the following code in Page_Load Event

if(!PostBack)
{
String postBackReferenceForListBox =
this.Page.GetPostBackClientEvent(btnForListBoxDoubleClick, "dblClickfromHiddenButton");

ListBox1.Attributes.Add("ondblclick", postBackReferenceForListBox);
}


3. Write the following code to handle Double Click event in the button’s click event

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

if(argument == "dblClickfromHiddenButton")
{

// logic to process the selected item from listbox goes here
}
}

The function GetPostBackClientEvent in step 2 obtains a reference to a client-side script function that causes, when invoked, a server postback to the form.



Responses

Author: miriam    02 Nov 2009Member Level: Bronze   Points : 2
don't work for me
the erorr I get when doubleClick:


Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
GetPostBackClientEvent  .  EVENTARGUMENT  .  Double Click in ASP.NET ListBox  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Implementing Tabs using MultiView Control : ASP.NET
Previous Resource: Make ASP.NET Ajax Pages to Load Faster using ScriptCombing
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use