Annoying NumericTextBox bug

2 posts, 0 answers
  1. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 06 Mar 2012 Link to this post

    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.?????

  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 09 Mar 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top