469,958 Members | 1,947 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

Firing a function on a doubleclick event

Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I know
it will work with Javascript, but how do I use javascript to run a server
side function? Currently, I am using a Next button to accept the change, but
it would be a faster UI to have the option to doubleclick instead.

thanks a ton!
david lozzi
Nov 19 '05 #1
5 2973
Hey David,
I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default,
I assume you mean a server side event? In that case you can enable the
autopostback of the listbox. You can then double click it and get the default
event. For example:

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string[] astr = new string[] {"a","b","c"};
this.ListBox1.DataSource = astr;
this.ListBox1.DataBind();
}
}

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Label1.Text = this.ListBox1.SelectedValue;
}

"David Lozzi" wrote:
Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I know
it will work with Javascript, but how do I use javascript to run a server
side function? Currently, I am using a Next button to accept the change, but
it would be a faster UI to have the option to doubleclick instead.

thanks a ton!
david lozzi

Nov 19 '05 #2
Let me start by answering your question. JavaScript is on the client. The
function you want to call is on the server. Therefore, to fire a function
with a JavaScript, the JavaScript needs to post the form back to the server.

Now, I can't help but think that your idea lacks some merit. Why? Because
browsers behave in known ways. When you write an app that runs in a browser,
you must expect that most people who use it will be familiar with browsers,
HTML documents, and web sites. They don't expect a double-click to fire
anything. This impacts usability. It is better to stick with the conventions
that people are used to. IMHO, changing the behavior of the browser will
only confuse people.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"David Lozzi" <dlozzi@(remove)delphi-ts.com> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...
Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I
know it will work with Javascript, but how do I use javascript to run a
server side function? Currently, I am using a Next button to accept the
change, but it would be a faster UI to have the option to doubleclick
instead.

thanks a ton!
david lozzi

Nov 19 '05 #3
Thank you for your input. I am fully aware of Javascript and client/server
side functions. This is why I am asking how to access/post/request/fire off
a server event from javascript. The ondoubleclick event is client side only.
I am needing to create the doubleclick event because my client's existing
application that I am replacing uses doubleclick events to select items. And
regarding what most people are familiar with, every user I have worked with
doubleclick every day, and I'd imagine you do too (open files and programs
in your OS). Weaker users doubleclick everything on websites because thats
what they know from the operating system. I am into pleasing the customer
and idiot proofing as much as possible.

Thanks again,

David Lozzi

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Let me start by answering your question. JavaScript is on the client. The
function you want to call is on the server. Therefore, to fire a function
with a JavaScript, the JavaScript needs to post the form back to the
server.

Now, I can't help but think that your idea lacks some merit. Why? Because
browsers behave in known ways. When you write an app that runs in a
browser, you must expect that most people who use it will be familiar with
browsers, HTML documents, and web sites. They don't expect a double-click
to fire anything. This impacts usability. It is better to stick with the
conventions that people are used to. IMHO, changing the behavior of the
browser will only confuse people.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"David Lozzi" <dlozzi@(remove)delphi-ts.com> wrote in message
news:eo**************@TK2MSFTNGP09.phx.gbl...
Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I
know it will work with Javascript, but how do I use javascript to run a
server side function? Currently, I am using a Next button to accept the
change, but it would be a faster UI to have the option to doubleclick
instead.

thanks a ton!
david lozzi


Nov 19 '05 #4
This fires even when I single click on the list box.

Can I point to or cause a server side function to fire?

Thanks,

David Lozzi
"Tim Stall" <Ti******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
Hey David,
I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default,


I assume you mean a server side event? In that case you can enable the
autopostback of the listbox. You can then double click it and get the
default
event. For example:

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string[] astr = new string[] {"a","b","c"};
this.ListBox1.DataSource = astr;
this.ListBox1.DataBind();
}
}

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
this.Label1.Text = this.ListBox1.SelectedValue;
}

"David Lozzi" wrote:
Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I
know
it will work with Javascript, but how do I use javascript to run a server
side function? Currently, I am using a Next button to accept the change,
but
it would be a faster UI to have the option to doubleclick instead.

thanks a ton!
david lozzi

Nov 19 '05 #5
Okay, I think I see it: You have a client side function, and you want that to
call a Server-side function? If so, maybe this page will help:
Passing client data to the server
http://timstall.dotnetdevelopersjour...ad/1118970.htm

Essentially it shows how to have a client side function pass data back to
the server via (1) setting a runat=server hidden field, and (2) submitting
the form.

"David Lozzi" wrote:
This fires even when I single click on the list box.

Can I point to or cause a server side function to fire?

Thanks,

David Lozzi
"Tim Stall" <Ti******@discussions.microsoft.com> wrote in message
news:1E**********************************@microsof t.com...
Hey David,
I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default,


I assume you mean a server side event? In that case you can enable the
autopostback of the listbox. You can then double click it and get the
default
event. For example:

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string[] astr = new string[] {"a","b","c"};
this.ListBox1.DataSource = astr;
this.ListBox1.DataBind();
}
}

private void ListBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
this.Label1.Text = this.ListBox1.SelectedValue;
}

"David Lozzi" wrote:
Hey All,

I have a listbox that I would like to fire an event on doubleclick. the
onDoubleClick property of the listbox isnt available be default, and I
know
it will work with Javascript, but how do I use javascript to run a server
side function? Currently, I am using a Next button to accept the change,
but
it would be a faster UI to have the option to doubleclick instead.

thanks a ton!
david lozzi


Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by René Meinecke | last post: by
2 posts views Thread by JoeHenrich | last post: by
4 posts views Thread by Tor Inge Rislaa | last post: by
1 post views Thread by Tom | last post: by
3 posts views Thread by C Glenn | last post: by
4 posts views Thread by _DD | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.