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

RadTextBox - Issue with set_enabled(false)

3 Answers 395 Views
Input
This is a migrated thread and some comments may be shown as answers.
Brindavan
Top achievements
Rank 1
Brindavan asked on 22 Apr 2009, 02:28 PM
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);

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Apr 2009, 05:41 AM
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.
0
Sonia
Top achievements
Rank 1
answered on 05 Nov 2013, 12:01 PM
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.
0
Princy
Top achievements
Rank 2
answered on 15 Nov 2013, 12:54 PM
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.
Tags
Input
Asked by
Brindavan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sonia
Top achievements
Rank 1
Share this question
or