<asp
ropDownList id="blah" runat="server" onmousewheel="return
false;"></asp
ropDownList>
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.