radmaskedtextbox mousewheel changes data

12 posts, 0 answers
  1. Shif
    Shif avatar
    5 posts
    Member since:
    Jun 2012

    Posted 24 Jun 2012 Link to this post

    Hi!
    The mouse wheel  changes the data in the RadMaskedTextBox  I would like to disable the mouse wheel to change it.
    does anybody have an idea?
    <telerik:RadMaskedTextBox ID="datatxtIn1" runat="server" CssClass="editorTime" SelectionOnFocus="SelectAll"  
                                                                 PromptChar="_" Width="30px" BorderStyle="None" RoundNumericRanges="false">
                                                   <ClientEvents OnValueChanged="InOut_ValueChanges" OnFocus="InOut_OnFocus" /> 
                                       </telerik:RadMaskedTextBox>

    Thank's
    Shif
  2. Rick Aberle
    Rick Aberle avatar
    18 posts
    Member since:
    Nov 2005

    Posted 25 Jun 2012 Link to this post

    Same problem here. Does anyone from telerik team knows if there is a setting or a workaround.

    Thanks,
    Binyam
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 27 Jun 2012 Link to this post

    Hello,

    Set onmousewheel="preventDefault(event)" in the markup of your MaskedTextBox
    And define such JavaScript function:
    function preventDefault(e) {
      e = e || window.event;
      if (e.preventDefault)
          e.preventDefault();
      e.returnValue = false
    }


    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Rick Aberle
    Rick Aberle avatar
    18 posts
    Member since:
    Nov 2005

    Posted 27 Jun 2012 Link to this post

    Thanks Vasil.
    But the suggested solution doesn't work. The event is already subscribed in the telerik client side javascript object representation of the control and only works for subsequent evnets fired from the radmasked text box and failed to prevent the mousewheel event the first time.
    I have also tried to cancel the event from the clientevents section of the radmasked text box with no luck:

     function cancelEvent(source, eventArgs) {
                eventArgs.set_cancel(true);
            }

    <telerik:RadMaskedTextBox runat="server" ID="radTxtBoxMaskedValue" >

    <ClientEvents OnMoveUp="cancelEvent" OnMoveDown="cancelEvent" ></ClientEvents>

    </telerik:RadMaskedTextBox>


    I think this needs to be implemented the same way as the radnumerictextbox incrementsettings. Which works perfectly.
    <IncrementSettings InterceptMouseWheel="False"></IncrementSettings>

    Thanks,
    Binyam

  6. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 28 Jun 2012 Link to this post

    Hello Binyam,

    You can override the mousewheel handler of the masked text box to do nothing. Just add this JavaScript under the declaration of your script manager.

    if (Telerik.Web.UI.RadMaskedTextBox)
    {
    Telerik.Web.UI.RadMaskedTextBox.prototype._onTextBoxMouseWheelHandler = function (e)
    {
        return;
    }
     
    }


    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  7. Eli Avni
    Eli Avni avatar
    3 posts
    Member since:
    Jul 2008

    Posted 28 Jun 2012 Link to this post

    It Works,

    Thanks
  8. Rick Aberle
    Rick Aberle avatar
    18 posts
    Member since:
    Nov 2005

    Posted 28 Jun 2012 Link to this post

    Thanks. overrinding of the mousewheel handler of the masked text box with an empty function solved our problem.
  9. Alvaro
    Alvaro avatar
    7 posts
    Member since:
    Jul 2010

    Posted 01 Oct 2013 Link to this post

    Hi Vasil:

    How this would work in a RadGrid with a Template Column? Because i tried with that function, and it only works if i have the RadMaskedTextBoxes loaded in the RadGrid.

    Thanks.
  10. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 02 Oct 2013 Link to this post

    Hi Alvaro,

    This would work for all RadMaskedTextBoxes in your page. It will not matter if they are in grid or not.

    I am not sure that I understand your question correctly. If you still have any troubles, please explain in further details what exactly is the case, and give us some examples.

    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  11. Alvaro
    Alvaro avatar
    7 posts
    Member since:
    Jul 2010

    Posted 02 Oct 2013 Link to this post

    Hi Vasil:

    Thanks for your quickly reply.

    Basically, I have a register form. In edit mode (an existent record) it loads the RadGrid with data in the RadMaskedTextBox in the template column and the mouse wheel event is disabled. But when in create a new record, the RadGrid is empty until I select some filters. Then,  when the RadGrid is filled (the RadMaskedTextBox), the mouse wheel event is enabled. 

    I don't know if this is associated with the DataBound event.

    I used the javascript function mentioned above:

        $(document).ready(function () {
    if (Telerik.Web.UI.RadMaskedTextBox) {
    Telerik.Web.UI.RadMaskedTextBox.prototype._onTextBoxMouseWheelHandler =
    function (e) {
                    
    return;
    }
        }
    });

    Note: The mask used in the RadMaskedTextBox is a TimeSpan input  (  00:00 =>  Mask="<0..8>:<0..59>" )

    Regards.
  12. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 04 Oct 2013 Link to this post

    Hello Alvaro,

    Handle the pageLoad instead of $(document).ready. Because if you execute the script too early, the Telerik.Web.UI.RadMaskedTextBox will not be defined, so you will not override its function.
    function pageLoad()
    {
       if (Telerik.Web.UI.RadMaskedTextBox) {
        Telerik.Web.UI.RadMaskedTextBox.prototype._onTextBoxMouseWheelHandler = function (e)
          {
              return;
          }
        }
    }


    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  13. Alvaro
    Alvaro avatar
    7 posts
    Member since:
    Jul 2010

    Posted 30 Oct 2013 Link to this post

    After some time, I finally found a way to block the mousewheel event, so I want to share the solution (that it worked for me):

    Javascript:

    function BlockMouseWheel(e) {
        //jQuery
        $('#' + e.id).val(e._oldValue);
    }

    Markup:

    <telerik:RadMaskedTextBox onmousewheel="BlockMouseWheel(this)" ....

    Regards.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017