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

RddNumeric Textbox - Onblur event triggering on Readonly

2 Answers 44 Views
Input
This is a migrated thread and some comments may be shown as answers.
Rhbkv
Top achievements
Rank 1
Rhbkv asked on 11 Jan 2013, 07:43 AM
Hi,
We are using RadnumericTextbox to hold numeric value. We have formatText method on Onblur event to format the entered value.
On Form load, we have set  the RadnumericTextbox as readonly (since we do not want enabled=false). Onblur event was not triggering when textbox is readonly and did not show formated text as 0.00 (since textbox is empty) till we upgrade to telerik version 2012.2.912.40
After upgrade, RadnumericTextbox is triggering onblur event even if it is readonly.
Is there any way to check whether RadnumericTextbox is readonly or not in Javascript?
Since we have many RadnumericTextbox in the form we have used generic javascript method to format a text as below

 

 

function FormatText(sender, args) {

 

 

 

var num  = sender.get_value();

 

 

 

if (num == "" || num == "undefined") {

 

num = 0.00

}

 

 

var result = num.toFixed(2);

 

sender.set_value( result);

sender._textBoxElement.value = num.toFixed(2);

}


In this method, is it possible to check whether "Sender" is readonly or not to avoid formating?
Thanks

2 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 15 Jan 2013, 03:33 PM

Hi Rhbkv,

It would be difficult to check the status of your RadNumericTextBox in Javascript, but it would be possible to do in C# in the event handler. You would just need to change the type of sender from Object to RadNumericTextBox. Hopefully this will help with what you are trying to do.

protected void RadNumericTextBox1_OnBlur(RadNumericTextBox sender, EventArgs e)
{
    if (sender.ReadOnly == false)
    {
        sender.ReadOnly = true;
    }
}

Good Luck,
Bart
0
Vasil
Telerik team
answered on 16 Jan 2013, 07:13 AM
Hi,

You can check the readOnly from the visible element directly. Here is example JavaScript:

function blurHandler(sender, args)
{
    if ( ! sender.get_element().readOnly)
    {
        //do your logic
    }
}

Greetings,
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.
Tags
Input
Asked by
Rhbkv
Top achievements
Rank 1
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
Vasil
Telerik team
Share this question
or