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

Toggle readonly client side and no value on postback

4 Answers 121 Views
Input
This is a migrated thread and some comments may be shown as answers.
MarkInTexas
Top achievements
Rank 1
MarkInTexas asked on 15 Nov 2010, 10:31 PM
<script type="text/javascript"
function setReadOnly() 
    var TextBox1 = $find("<%= RadTextBox1.ClientID %>"); 
    TextBox1._textBoxElement.readOnly = state
function clearReadOnly() 
    var TextBox1 = $find("<%= RadTextBox1.ClientID %>"); 
    TextBox1._textBoxElement.readOnly = false
 
</script>

Using the above to toggle a textbox readonly flag. Setting back readonly = false and then entering a value into the textbox, upon postback the value is empty.

Question : How to toggle readonly flag client side and make control behave correctly upon postback?

*** Note: Here is the strange part, the control only fails (empty string) on the first postback - after that things work correctly.

More Info: On the first postback - the ReadOnly flag on the server side is false. So setting readonly  to false in java-script did not update something and serverside the flag is still true. I think that why the value is empty.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Nov 2010, 08:23 AM
Hello Crownmark,


How about setting Enabled property than setting ReadOnly property? Check the following forum which discussed almost similar scenario.
Readonly Textbox clearing on postback

And this forum also: RadTextBox Set Read Only

It is possible to enable/disable the RadTextBox from client side using enable()/disable() methods. For more information about the client side methods: RadTextBox Client Object


-Shinu.
0
MarkInTexas
Top achievements
Rank 1
answered on 16 Nov 2010, 02:25 PM
Thanks for the quick response. I have read that post. But I am setting the readonly flag to false. The control should accept input if the control is NOT readonly. Long story, but I do not want to use the enabled property. Using the readonly property should work fine. Any thoughts to why the text field is empty when posting back?
0
Veli
Telerik team
answered on 19 Nov 2010, 04:18 PM
Hi crownmark,

Are you using the latest 2010 Q3 version of Telerik RadConrols? Testing the scenario with this version, it seems to work OK on my side. Attaching the test page I have used. Can you try to reproduce this issue in it?

Veli
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
MarkInTexas
Top achievements
Rank 1
answered on 19 Nov 2010, 09:14 PM
Our current version of Telerik is one version back. It is on the queue to update to the latest, just waiting approval from mgmt.
Thanks for the example, I will try it and report back.
Tags
Input
Asked by
MarkInTexas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
MarkInTexas
Top achievements
Rank 1
Veli
Telerik team
Share this question
or