radTextbox doesn't hold value in service side code

2 posts, 0 answers
  1. dhuss
    dhuss avatar
    120 posts
    Member since:
    Sep 2009

    Posted 04 Dec 2012 Link to this post

    I have a radtextbox that I am updating the text with JavaScript (clientside). The new value shows on the page but if I access the control server side, it shows the old value. This control is not being reloaded server side.

    JavaScript: this will set the new value which shows up on the web page

    document.Form1.txtTotalCharge_text.value = document.Form1.txtHdTotalCharge.value

    If I access txtTotalCharge.text on the server side, the old value shows up. The asp:textbox doesn't have this issue. Can anyone tell me how to fix this.

  2. Milena
    Admin
    Milena avatar
    257 posts

    Posted 07 Dec 2012 Link to this post

    Hello,

    In order to set text to RadTextBox client-side, it is needed to access the client object of the textbox and use set_value() method as it is shown below:
    <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
          <script type="text/javascript">
              function loaded() {
                  txt = $find("<%= tb1.ClientID %>");
                  txt.set_value("test");
     
              }
          </script>
      </telerik:RadCodeBlock>

    Additionally, you can set AutoPostBack="true" to access this value server-side.
    <telerik:RadTextBox runat="server" ID="tb1" AutoPostBack="true">
            <ClientEvents OnLoad="loaded" />
        </telerik:RadTextBox>

    Kind regards,
    Milena
    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