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

Annoying NumericTextBox bug

1 Answer 77 Views
Input
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 06 Mar 2012, 03:23 PM
Hi

Well I finally came up with some client side code to enable and disable my TextBoxes and by extension I figured out how to manipulate NumericTextboxes.

Only to find the following gotcha.

If I initially set the NumericTextBoxes to disabled in server side code I can never enable them.

If they are initially enabled in server side code I can disable and enable them to my hearts content.

Any ideas?

Here is the server side and client side code I'm using.

C#:

 

 

if (saParam[1] == 'Always')

 

{

AlwaysRadioButton.Checked =

 

true;

 

ConnectionNameTextBox.ReadOnly =

 

true;

 

InitiateConnectionCheckBox.Enabled =

 

false;

 

WaitRadNumericTextBox.Enabled =

 

false;

 

DelayRadNumericTextBox.Enabled =

 

false;

 

}

 

 

else if (saParam[1] == 'Any')

 

{

RunIfAnyRadioButton.Checked =

 

true;

 

ConnectionNameTextBox.ReadOnly =

 

true;

 

InitiateConnectionCheckBox.Enabled =

 

false;

 

WaitRadNumericTextBox.Enabled =

 

true;

 

DelayRadNumericTextBox.Enabled =

 

true;

 

}

 

 

else if (saParam[1] == 'Specific')

 

{

SpecificRadioButton.Checked =

 

true;

 

ConnectionNameTextBox.ReadOnly =

 

false;

 

InitiateConnectionCheckBox.Enabled =

 

true;

 

WaitRadNumericTextBox.Enabled =

 

true;

 

DelayRadNumericTextBox.Enabled =

 

true;

 

}

javascript:

 

function

 

 

DisableDelayWaitControls( bDisabled )

 

{

 

 

var ntbDelay = $find( "CriteriaDelayRadNumericTextBox" );

 

 

 

var ntbDelayUp = document.getElementById( "CriteriaDelayRadNumericTextBox" + "_SpinUpButton" );

 

 

 

var ntbDelayDown = document.getElementById( "CriteriaDelayRadNumericTextBox" + "_SpinDownButton" );

 

 

 

var ntbWait = $find( "CriteriaWaitRadNumericTextBox" );

 

 

 

var ntbWaitUp = document.getElementById( "CriteriaWaitRadNumericTextBox" + "_SpinUpButton");

 

 

 

var ntbWaitDown = document.getElementById( "CriteriaWaitRadNumericTextBox" + "_SpinDownButton" );

 

ntbDelay.disabled = bDisabled;

ntbWait.disabled = bDisabled;

ntbDelay._textBoxElement.disabled = bDisabled;

ntbDelayUp.disabled = bDisabled;

ntbDelayDown.disabled = bDisabled;

ntbWait._textBoxElement.disabled = bDisabled;

ntbWaitUp.disabled = bDisabled;

ntbWaitDown.disabled = bDisabled;

}

If the 'Always' code branch is executed I can never enable my controls in javascript.?????

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 09 Mar 2012, 08:23 AM
Hello Tim,

Generally the end user is able to override/change/modify all JavaScript loaded into his browser. In this manner you could always change the behavior of the input ClientSide. However this by design should not affect to it's server side settings.
Disabling the TextBox client side if it is enabled server side will mean just to submit null value. (Which on server side does not make any difference if is enabled or disabled, it just submits empty string).
However if the control is disabled server side, it will not care of the submitted value, it should always ignore it.

So if you want your user to be able to change the input, you should enable it ServerSide, and then disable/enable it client side just for representative purposes.

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