Firing a function on a doubleclick event

Discussion in 'ASP .Net' started by David Lozzi, Mar 9, 2005.

  1. David Lozzi

    David Lozzi Guest

    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
     
    David Lozzi, Mar 9, 2005
    #1
    1. Advertising

  2. 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
    >
    >
    >
     
    =?Utf-8?B?VGltIFN0YWxs?=, Mar 9, 2005
    #2
    1. Advertising

  3. 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:eog$...
    > 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
    >
     
    Kevin Spencer, Mar 9, 2005
    #3
  4. David Lozzi

    David Lozzi Guest

    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" <> wrote in message
    news:%23v$...
    > 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:eog$...
    >> 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
    >>

    >
    >
     
    David Lozzi, Mar 9, 2005
    #4
  5. David Lozzi

    David Lozzi Guest

    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" <> wrote in message
    news:...
    > 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
    >>
    >>
    >>
     
    David Lozzi, Mar 9, 2005
    #5
  6. 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" 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" <> wrote in message
    > news:...
    > > 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
    > >>
    > >>
    > >>

    >
    >
    >
     
    =?Utf-8?B?VGltIFN0YWxs?=, Mar 9, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Buddy Ackerman

    No Doubleclick event on a Listbox control?

    Buddy Ackerman, May 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    2,142
    Brock Allen
    May 19, 2005
  2. wensa
    Replies:
    1
    Views:
    3,260
    Thomas Weidenfeller
    Jan 18, 2006
  3. =?Utf-8?B?cGVsZWdrMQ==?=

    asp.net 2 : asp:listbox doubleclick and fire event

    =?Utf-8?B?cGVsZWdrMQ==?=, Aug 31, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    845
    bruce barker
    Sep 1, 2007
  4. Chris Zopers

    Doubleclick event in DataView

    Chris Zopers, Feb 12, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    375
    Michael Nemtsev [MVP]
    Feb 12, 2008
  5. DoubleClick Event on ListBox

    , Mar 18, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    188
Loading...

Share This Page