Readonly Textbox clearing on postback

7 posts, 1 answers
  1. Omlac
    Omlac avatar
    64 posts
    Member since:
    Jul 2008

    Posted 19 Nov 2008 Link to this post

    Hi all
    im trying to add a readonly textbox on my form but the problem is it keeps clearing the textbox on postback, if i remove the read only property it works fine.

    Does anyone know whats causing this.
  2. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 19 Nov 2008 Link to this post

    Hello Omlac,


    The Text value of the RadTextBox control with the ReadOnly property set to true is sent to the server when a postback occurs, but the server does no processing for a read-only text box. This prevents a malicious user from changing a Text value that is read-only. The value of the Text property is preserved in the view state between postbacks unless modified by server-side code.

    Greetings,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Omlac
    Omlac avatar
    64 posts
    Member since:
    Jul 2008

    Posted 24 Nov 2008 Link to this post

    Thank you very much for your response,
    Does that mean i cant use a readonly Textbox when i want to keep the value displayed, suprisingly though i have another textbox on the same form whick keeps its value even after postback.

    Regards
  5. Answer
    Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 27 Nov 2008 Link to this post

    Hello Omlac,

    As explained in this help article you cannot change the Text value of the RadInput control when its ReadOnly property is set to "true". In short, if you intend to modify the value of the control you should not use ReadOnly. If you want to be able to change the Text value (via client or server code) and at the same time prevent the user from doing so, you can use the Enabled="false" property. I hope this helps.

    Best wishes,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Ubirajara
    Ubirajara avatar
    1 posts
    Member since:
    Nov 2011

    Posted 10 Nov 2011 Link to this post

    Hi, Im mexican, i had the same problem, the solution is..

    add in the event Page_Load in the codebehind file
    protected void Page_Load(object sender, EventArgs e)
            {
                textboxId.Attributes.Add("readonly", "true");
            }

    that works funny
  7. Francis
    Francis avatar
    15 posts
    Member since:
    Mar 2011

    Posted 14 Jun 2012 Link to this post

    Hi, I have almost the same problem.

    I have a RadTextBox control with Enabled="false". I change his value in Javascript. Then a PostBack occurs (after a change in a cutom AutoComplete control), the original value is displayed in the TextBox.

    I have PageLoad event, but all the code is in a if(!IsPostBack) test...

    Any idea ?


    PS: version 2012.1.411.40
  8. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 15 Jun 2012 Link to this post

    Hello Francis,

    When RadTextBox is disabled (Enabled="false") the text can not be changed client side by the user. Even if you change it using JavaScript or editing the DOM using some developer tools, the changes will not reflect to server side values.

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