This is a migrated thread and some comments may be shown as answers.

radmaskedtextbox mousewheel changes data

11 Answers 156 Views
Input
This is a migrated thread and some comments may be shown as answers.
Shif
Top achievements
Rank 1
Shif asked on 24 Jun 2012, 06:58 AM
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

11 Answers, 1 is accepted

Sort by
0
Rick Aberle
Top achievements
Rank 1
answered on 25 Jun 2012, 11:08 PM
Same problem here. Does anyone from telerik team knows if there is a setting or a workaround.

Thanks,
Binyam
0
Vasil
Telerik team
answered on 27 Jun 2012, 03:18 PM
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.
0
Rick Aberle
Top achievements
Rank 1
answered on 27 Jun 2012, 05:56 PM
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

0
Vasil
Telerik team
answered on 28 Jun 2012, 09:06 AM
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.
0
Eli Avni
Top achievements
Rank 1
answered on 28 Jun 2012, 10:46 AM
It Works,

Thanks
0
Rick Aberle
Top achievements
Rank 1
answered on 28 Jun 2012, 04:03 PM
Thanks. overrinding of the mousewheel handler of the masked text box with an empty function solved our problem.
0
Alvaro
Top achievements
Rank 1
answered on 01 Oct 2013, 11:21 PM
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.
0
Vasil
Telerik team
answered on 02 Oct 2013, 05:54 AM
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.
0
Alvaro
Top achievements
Rank 1
answered on 02 Oct 2013, 03:18 PM
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.
0
Vasil
Telerik team
answered on 04 Oct 2013, 11:48 AM
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.
0
Alvaro
Top achievements
Rank 1
answered on 30 Oct 2013, 05:19 PM
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.
Tags
Input
Asked by
Shif
Top achievements
Rank 1
Answers by
Rick Aberle
Top achievements
Rank 1
Vasil
Telerik team
Eli Avni
Top achievements
Rank 1
Alvaro
Top achievements
Rank 1
Share this question
or