double click event on listbox

J

Jeff User

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
 
L

Lit

Jeff,

I don't 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
 
G

Guest

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

Jeff User

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

Thanks
jeff
 
G

Guest

Jeff,

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

Jim Brodie

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

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

:

Previous Posts In This Thread:

double click event on listbox
H
Using .NET 1.1, C#, web ap

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

Any idea how to go about this

Thank
Jeff

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 nee
that functionality or possibly a Ctrl-Clic

hope someone will give us an answer

Lit

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

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

:

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

Thank
jeff

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 specifi
- you should be able to use it in ListBox

:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Get Silverlight 4 Installed: Tips and Tricks
http://www.eggheadcafe.com/tutorial...b-f54c56a64ed9/get-silverlight-4-install.aspx
 
M

Mark Rae [MVP]

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

There are literally dozens of articles on the web which talk about this and
explain how to do it: http://tinyurl.com/y2sald4

The first two will almost certainly be all you'll need...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top