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

radTextbox doesn't hold value in service side code

1 Answer 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
dhuss
Top achievements
Rank 1
dhuss asked on 04 Dec 2012, 07:33 PM

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.

1 Answer, 1 is accepted

Sort by
0
Milena
Telerik team
answered on 07 Dec 2012, 09:49 AM
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.
Tags
General Discussions
Asked by
dhuss
Top achievements
Rank 1
Answers by
Milena
Telerik team
Share this question
or