Firing a function on a doubleclick event

D

David Lozzi

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
 
G

Guest

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;
}
 
K

Kevin Spencer

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

David Lozzi

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
 
D

David Lozzi

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 said:
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 said:
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
 
G

Guest

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.dotnetdevelopersjournal.com/read/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 said:
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 said:
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 said:
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
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top