From: Jim on
I've added that code into the code behind file of a ASP webpage i'm build and I'm still unable to get a double click event. Am I doing this right? Also, I'm running .NET 3.5

Thanks. Jim



SergeyPoberezovski wrote:

You will need to define this event by yourself - override the
23-Aug-07

You will need to define this event by yourself - override the DropDownList:

public class myDropDownList : DropDownList, IPostBackEventHandler
{
public event EventHandler DblClick;
private const string _DOUBLE_CLICK = "dbl";

protected virtual void OnDblClick(EventArgs e)
{
if (DblClick!= null)
{
DblClick(this, e);
}
}

protected override void OnInit(EventArgs e)
{
if (this.Page != null)
{
this.Page.RegisterRequiresControlState(this);
}
base.OnInit(e);
}

protected void Page_PreRender(object sender, EventArgs e)
{
string script = this.Page.GetPostBackEventReference(this, _DOUBLE_CLICK);
this.Attributes.Add("ondblclick", script);
}

void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
if (eventArgument == _DOUBLE_CLICK)
{
this.OnDblClick(EventArgs.Empty);
}
}
}

Please note that I do not have 1.1 handy - and the code above I compiled
from a similar control in 2.0 - so there might be some syntax errors - I just
wanted to get you an idea of how this could be accomplished.

"Lit" wrote:

Previous Posts In This Thread:

On Wednesday, August 22, 2007 7:41 PM
Jeff User wrote:

double click event on listbox
Hi
Using .NET 1.1, C#, web app

I (actually our client) would like to be able to double click a
selection in a listbox and have it postback to server . There I would
want to access the item that was double clicked.

Any idea how to go about this?

Thanks
Jeff

On Wednesday, August 22, 2007 8:22 PM
Lit wrote:

Jeff,I don't see a double click on a listbox. I been looking for this.
Jeff,

I do not see a double click on a listbox. I been looking for this. I need
that functionality or possibly a Ctrl-Click

hope someone will give us an answer.

Lit

On Thursday, August 23, 2007 1:44 AM
SergeyPoberezovski wrote:

You will need to define this event by yourself - override the
You will need to define this event by yourself - override the DropDownList:

public class myDropDownList : DropDownList, IPostBackEventHandler
{
public event EventHandler DblClick;
private const string _DOUBLE_CLICK = "dbl";

protected virtual void OnDblClick(EventArgs e)
{
if (DblClick!= null)
{
DblClick(this, e);
}
}

protected override void OnInit(EventArgs e)
{
if (this.Page != null)
{
this.Page.RegisterRequiresControlState(this);
}
base.OnInit(e);
}

protected void Page_PreRender(object sender, EventArgs e)
{
string script = this.Page.GetPostBackEventReference(this, _DOUBLE_CLICK);
this.Attributes.Add("ondblclick", script);
}

void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
if (eventArgument == _DOUBLE_CLICK)
{
this.OnDblClick(EventArgs.Empty);
}
}
}

Please note that I do not have 1.1 handy - and the code above I compiled
from a similar control in 2.0 - so there might be some syntax errors - I just
wanted to get you an idea of how this could be accomplished.

"Lit" wrote:

On Thursday, August 23, 2007 9:32 AM
Jeff User wrote:

I want to do this with a listbox, not a dropdownlist.Is the procedure the same?
I want to do this with a listbox, not a dropdownlist.
Is the procedure the same?

Thanks
jeff

On Thursday, August 23, 2007 7:10 PM
SergeyPoberezovski wrote:

Jeff,The code that refers to handling double click event is not control
Jeff,

The code that refers to handling double click event is not control specific
- you should be able to use it in ListBox.

"Jeff User" wrote:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Get Silverlight 4 Installed: Tips and Tricks
http://www.eggheadcafe.com/tutorials/aspnet/05910e41-3846-4db9-8e1b-f54c56a64ed9/get-silverlight-4-install.aspx