disable scroll

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Oct 7, 2005.

  1. hey all,

    can someone please tell me if you can disable the scroll button for a
    dropdownlist. For example, when you select an item in a dropdownlist and it
    still has focus and you accidently hit scroll wheel on your mouse the
    selected item changes.

    can this be disabled?

    thanks,
    rodchar
     
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 7, 2005
    #1
    1. Advertising

  2. No.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Ambiguity has a certain quality to it.

    "rodchar" <> wrote in message
    news:...
    > hey all,
    >
    > can someone please tell me if you can disable the scroll button for a
    > dropdownlist. For example, when you select an item in a dropdownlist and
    > it
    > still has focus and you accidently hit scroll wheel on your mouse the
    > selected item changes.
    >
    > can this be disabled?
    >
    > thanks,
    > rodchar
     
    Kevin Spencer, Oct 7, 2005
    #2
    1. Advertising

  3. Rodchar,

    Depending on how your site is set up you may be able to take care of this. I
    find the list still being selected to be a problem after a page is posted
    back (say when filtering a datagrid) and then, when the filtered results are
    returned the scroll wheel is accidentally clicked starting the process over
    again.

    I use a javascript on post back to place the focus onto something else on
    the page.

    So, for example, in the post back event handler of the submit button (or the
    drop down list itself if it's set to autopostback) I use a startup script
    like:

    Page.RegisterStartupScript("MyFocusScript", "<script
    language=""javascript"">document.getElementById('MyDataGridClientIdHere');</script>")

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "rodchar" <> wrote in message
    news:...
    > hey all,
    >
    > can someone please tell me if you can disable the scroll button for a
    > dropdownlist. For example, when you select an item in a dropdownlist and
    > it
    > still has focus and you accidently hit scroll wheel on your mouse the
    > selected item changes.
    >
    > can this be disabled?
    >
    > thanks,
    > rodchar
     
    S. Justin Gengo, Oct 7, 2005
    #3
  4. =?Utf-8?B?cm9kY2hhcg==?=

    Damien Guest

    Kevin Spencer wrote:
    > No.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Ambiguity has a certain quality to it.
    >
    > "rodchar" <> wrote in message
    > news:...
    > > hey all,
    > >
    > > can someone please tell me if you can disable the scroll button for a
    > > dropdownlist. For example, when you select an item in a dropdownlist and
    > > it
    > > still has focus and you accidently hit scroll wheel on your mouse the
    > > selected item changes.
    > >
    > > can this be disabled?
    > >
    > > thanks,
    > > rodchar

    Sorry, cant see original message, but I'd say try something like the
    following:

    <asp:DropDownList id="blah" runat="server" onmousewheel="return
    false;"></asp:DropDownList>

    The onmousewheel will probably get a syntax wobbly line, but I think
    that should work (or you can add it via code if you want/if it doesn't
    work)

    Damien
     
    Damien, Oct 7, 2005
    #4
  5. that worked great, thanks. thanks everyone for the great feedback.

    "Damien" wrote:

    > Kevin Spencer wrote:
    > > No.
    > >
    > > --
    > > HTH,
    > >
    > > Kevin Spencer
    > > Microsoft MVP
    > > .Net Developer
    > > Ambiguity has a certain quality to it.
    > >
    > > "rodchar" <> wrote in message
    > > news:...
    > > > hey all,
    > > >
    > > > can someone please tell me if you can disable the scroll button for a
    > > > dropdownlist. For example, when you select an item in a dropdownlist and
    > > > it
    > > > still has focus and you accidently hit scroll wheel on your mouse the
    > > > selected item changes.
    > > >
    > > > can this be disabled?
    > > >
    > > > thanks,
    > > > rodchar

    > Sorry, cant see original message, but I'd say try something like the
    > following:
    >
    > <asp:DropDownList id="blah" runat="server" onmousewheel="return
    > false;"></asp:DropDownList>
    >
    > The onmousewheel will probably get a syntax wobbly line, but I think
    > that should work (or you can add it via code if you want/if it doesn't
    > work)
    >
    > Damien
    >
    >
     
    =?Utf-8?B?cm9kY2hhcg==?=, Oct 7, 2005
    #5
  6. > <asp:DropDownList id="blah" runat="server" onmousewheel="return
    > false;"></asp:DropDownList>
    >
    > The onmousewheel will probably get a syntax wobbly line, but I think
    > that should work (or you can add it via code if you want/if it doesn't
    > work)


    This will not prevent the select object from scrolling. I tested it with a
    pure HTML form. In addition, the "onmousewheel" event is proprietary to
    Microsoft IE.

    Justin did have an idea I hadn't thought of. However, he didn't post the
    JavaScript correctly (it referenced the element, but didn't write what it
    should do):

    Page.RegisterStartupScript("MyFocusScript", "<script
    language=""javascript"">document.getElementById('MyDataGridClientIdHere');</script>")

    I believe he meant:

    Page.RegisterStartupScript("MyFocusScript", "<script
    language=""javascript"">document.getElementById('MyDataGridClientIdHere').focus();</script>")

    This does not prevent the user from putting the focus on the select object
    and scrolling the mouse wheel, however. It does set the focus elsewhere when
    the page loads.

    On the other hand, it did make me think. Assuming again that *all of your
    users are using IE*, you COULD keep the "onmousewheel" event from changing
    the SelectedIndex of the select object. This would require a global
    JavaScript variable to store the current SelectedIndex of the select object
    in, and another to prevent the select object's "onchange" event from doing
    anything. You could define a JavaScript function that handles the
    "onmousewheel" event. It would check the global Selectedindex variable, set
    the global "prevent" variable to true, set the select object's SelectedIndex
    to the value of the variable, set the window.event.cancelBubble property to
    true, which cancels the event from bubbling up, and reset the global
    "prevent" variable to false. In addition, you would need an "onchange" event
    for the select object itself, which first checks the prevent variable, and
    if false, sets the global SelectedIndex variable to the new select object's
    SelectedIndex.

    Now, if anyone is NOT using IE, this should not prevent anything from
    happening normally, but will prevent the "onmousewheel" event from changing
    the SelectedIndex property of the select object on IE.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Ambiguity has a certain quality to it.

    "Damien" <> wrote in message
    news:...
    > Kevin Spencer wrote:
    >> No.
    >>
    >> --
    >> HTH,
    >>
    >> Kevin Spencer
    >> Microsoft MVP
    >> .Net Developer
    >> Ambiguity has a certain quality to it.
    >>
    >> "rodchar" <> wrote in message
    >> news:...
    >> > hey all,
    >> >
    >> > can someone please tell me if you can disable the scroll button for a
    >> > dropdownlist. For example, when you select an item in a dropdownlist
    >> > and
    >> > it
    >> > still has focus and you accidently hit scroll wheel on your mouse the
    >> > selected item changes.
    >> >
    >> > can this be disabled?
    >> >
    >> > thanks,
    >> > rodchar

    > Sorry, cant see original message, but I'd say try something like the
    > following:
    >
    > <asp:DropDownList id="blah" runat="server" onmousewheel="return
    > false;"></asp:DropDownList>
    >
    > The onmousewheel will probably get a syntax wobbly line, but I think
    > that should work (or you can add it via code if you want/if it doesn't
    > work)
    >
    > Damien
    >
     
    Kevin Spencer, Oct 7, 2005
    #6
  7. Kevin,

    Thanks for noticing that I forgot .focus() in that script!

    --
    Sincerely,

    S. Justin Gengo, MCP
    Web Developer / Programmer

    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche
    "Kevin Spencer" <> wrote in message
    news:%...
    >> <asp:DropDownList id="blah" runat="server" onmousewheel="return
    >> false;"></asp:DropDownList>
    >>
    >> The onmousewheel will probably get a syntax wobbly line, but I think
    >> that should work (or you can add it via code if you want/if it doesn't
    >> work)

    >
    > This will not prevent the select object from scrolling. I tested it with a
    > pure HTML form. In addition, the "onmousewheel" event is proprietary to
    > Microsoft IE.
    >
    > Justin did have an idea I hadn't thought of. However, he didn't post the
    > JavaScript correctly (it referenced the element, but didn't write what it
    > should do):
    >
    > Page.RegisterStartupScript("MyFocusScript", "<script
    > language=""javascript"">document.getElementById('MyDataGridClientIdHere');</script>")
    >
    > I believe he meant:
    >
    > Page.RegisterStartupScript("MyFocusScript", "<script
    > language=""javascript"">document.getElementById('MyDataGridClientIdHere').focus();</script>")
    >
    > This does not prevent the user from putting the focus on the select object
    > and scrolling the mouse wheel, however. It does set the focus elsewhere
    > when the page loads.
    >
    > On the other hand, it did make me think. Assuming again that *all of your
    > users are using IE*, you COULD keep the "onmousewheel" event from
    > changing the SelectedIndex of the select object. This would require a
    > global JavaScript variable to store the current SelectedIndex of the
    > select object in, and another to prevent the select object's "onchange"
    > event from doing anything. You could define a JavaScript function that
    > handles the "onmousewheel" event. It would check the global Selectedindex
    > variable, set the global "prevent" variable to true, set the select
    > object's SelectedIndex to the value of the variable, set the
    > window.event.cancelBubble property to true, which cancels the event from
    > bubbling up, and reset the global "prevent" variable to false. In
    > addition, you would need an "onchange" event for the select object itself,
    > which first checks the prevent variable, and if false, sets the global
    > SelectedIndex variable to the new select object's SelectedIndex.
    >
    > Now, if anyone is NOT using IE, this should not prevent anything from
    > happening normally, but will prevent the "onmousewheel" event from
    > changing the SelectedIndex property of the select object on IE.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Ambiguity has a certain quality to it.
    >
    > "Damien" <> wrote in message
    > news:...
    >> Kevin Spencer wrote:
    >>> No.
    >>>
    >>> --
    >>> HTH,
    >>>
    >>> Kevin Spencer
    >>> Microsoft MVP
    >>> .Net Developer
    >>> Ambiguity has a certain quality to it.
    >>>
    >>> "rodchar" <> wrote in message
    >>> news:...
    >>> > hey all,
    >>> >
    >>> > can someone please tell me if you can disable the scroll button for a
    >>> > dropdownlist. For example, when you select an item in a dropdownlist
    >>> > and
    >>> > it
    >>> > still has focus and you accidently hit scroll wheel on your mouse the
    >>> > selected item changes.
    >>> >
    >>> > can this be disabled?
    >>> >
    >>> > thanks,
    >>> > rodchar

    >> Sorry, cant see original message, but I'd say try something like the
    >> following:
    >>
    >> <asp:DropDownList id="blah" runat="server" onmousewheel="return
    >> false;"></asp:DropDownList>
    >>
    >> The onmousewheel will probably get a syntax wobbly line, but I think
    >> that should work (or you can add it via code if you want/if it doesn't
    >> work)
    >>
    >> Damien
    >>

    >
    >
     
    S. Justin Gengo, Oct 9, 2005
    #7
  8. =?Utf-8?B?cm9kY2hhcg==?=

    Damien Guest

    Kevin Spencer wrote:
    > > <asp:DropDownList id="blah" runat="server" onmousewheel="return
    > > false;"></asp:DropDownList>
    > >
    > > The onmousewheel will probably get a syntax wobbly line, but I think
    > > that should work (or you can add it via code if you want/if it doesn't
    > > work)

    >
    > This will not prevent the select object from scrolling. I tested it with a
    > pure HTML form. In addition, the "onmousewheel" event is proprietary to
    > Microsoft IE.
    >

    Well, it seems to work here. Admittedly, yes, only for IE. But shooting
    for the LCD (IE user insult coming up here), it's those users who are
    least likely to spot what is happening with the mousewheel.

    I'm using IE 6, and the following markup works:

    <html>
    <head>
    <title>Must have a Title</title>
    </head>
    <body>
    <select onmousewheel="return false;"><option
    value="1">1</option><option value="2">2</option><option value="square
    root of 2">3</option></select>
    </body>
    </html>

    (Incidentally, it also appears to work in Opera?)

    Damien
     
    Damien, Oct 10, 2005
    #8
  9. Well, I'll be darned, Damien. I tested your code, and it did indeed work! I
    wish I had posted my own experiment so that I could see what the difference
    was, but it is lost to me forever. Perhaps it was just too early in the
    morning for me, I just don't know.

    In any case, I stand corrected. My apologies.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Ambiguity has a certain quality to it.

    "Damien" <> wrote in message
    news:...
    > Kevin Spencer wrote:
    >> > <asp:DropDownList id="blah" runat="server" onmousewheel="return
    >> > false;"></asp:DropDownList>
    >> >
    >> > The onmousewheel will probably get a syntax wobbly line, but I think
    >> > that should work (or you can add it via code if you want/if it doesn't
    >> > work)

    >>
    >> This will not prevent the select object from scrolling. I tested it with
    >> a
    >> pure HTML form. In addition, the "onmousewheel" event is proprietary to
    >> Microsoft IE.
    >>

    > Well, it seems to work here. Admittedly, yes, only for IE. But shooting
    > for the LCD (IE user insult coming up here), it's those users who are
    > least likely to spot what is happening with the mousewheel.
    >
    > I'm using IE 6, and the following markup works:
    >
    > <html>
    > <head>
    > <title>Must have a Title</title>
    > </head>
    > <body>
    > <select onmousewheel="return false;"><option
    > value="1">1</option><option value="2">2</option><option value="square
    > root of 2">3</option></select>
    > </body>
    > </html>
    >
    > (Incidentally, it also appears to work in Opera?)
    >
    > Damien
    >
     
    Kevin Spencer, Oct 10, 2005
    #9
    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. nicholas
    Replies:
    0
    Views:
    443
    nicholas
    Dec 7, 2004
  2. Kevin
    Replies:
    1
    Views:
    9,547
    Roland
    Feb 5, 2005
  3. Sathiamoorthy

    Enable Scroll up and scroll down in CR-report

    Sathiamoorthy, Nov 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    907
    zobalee
    Nov 28, 2006
  4. UJ
    Replies:
    1
    Views:
    591
    John Timney \(MVP\)
    Nov 1, 2006
  5. =?Utf-8?B?Ui5OaWprYW1w?=

    Listbox disabled - cant scroll in IE - can scroll in Firefox

    =?Utf-8?B?Ui5OaWprYW1w?=, Nov 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,238
    =?Utf-8?B?Ui5OaWprYW1w?=
    Nov 22, 2006
Loading...

Share This Page