RadTextBox - Issue with set_enabled(false)

4 posts, 0 answers
  1. Brindavan
    Brindavan avatar
    12 posts
    Member since:
    Feb 2009

    Posted 22 Apr 2009 Link to this post

    Hi,

    I wrote the following code in javascript
    if(...)
    { var controltodisable= $find("<%= ControlToDisable.ClientID %>");
    controltodisable.set_enabled(false);}

    Here, ControlToDisable is a RadTextBox.
    With the above code the textbox looks disabled but I am still able to type text in it. The text appears greyed out though.

    How can I resolve the issue?

    Also, when I disable the same textbox from clientside (JS) and codebehind (CS) there is a difference in the field display style.
    What could be the issue?

    Brindavan

    storageUnit1.set_enabled(false);
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Apr 2009 Link to this post

    Hi Brindavan,

    Try using the disable() method in order to disable the RadTextBox from client side.

    [ASPX]
     
    <telerik:RadTextBox ID="ControlToDisable" runat="server">  
    </telerik:RadTextBox> 

    [JacaScript]
     
    <script type="text/javascript">  
    function Disable()  
    {  
        var RadTextBox1 = $find("<%= ControlToDisable.ClientID %>");  
        RadTextBox1.disable();  
    }  
    </script> 
    RadTextBox Client Object

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sonia
    Sonia avatar
    90 posts
    Member since:
    Mar 2012

    Posted 05 Nov 2013 Link to this post

    Hi Princy,

    I have tested your solution and the control behaves correctly. However when I come back to the server after clicking on a button, value from the disabled textbox cannot be read.
    I solved that problem by enabling again the RadTextBox control on the OnClientClick method of the button.
    But i was wondering if there is a better way to do that.

    Thanks,
    Sonia.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Nov 2013 Link to this post

    Hi Sonia,

    For such scenarios I suggest you set the RadTextBox to ReadOnly instead of disabling the whole control. You can try the following code to make a RadTextBox ReadOnly from client side.

    JavaScript:
    <script type="text/javascript"
    function setReadOnly() 
        var TextBox1 = $find("<%= RadTextBox1.ClientID %>"); 
        TextBox1._textBoxElement.readOnly = true
    </script>

    Hope this helps,
    Princy.
Back to Top