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

Cannot get the changed value of a radtextbox on server side

2 Answers 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
NMA
Top achievements
Rank 1
NMA asked on 04 Dec 2008, 01:12 PM
I have a strange problem with a sample test web application.

I put a single radtextbox on the aspx page along with a standard asp.net button. What I do is, I set the value to the text property of the radtextbox in Page_Load method and after I change the value of the radtextbox and click the button to go to the server side, the text value is still the same.

Same thing applies to all radinput controls, radeditor, etc.

Am I doing something wrong?

Here are the contents of my sample application:
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TESTAPP._Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"><asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
    <telerik:RadTextBox ID="RadTextBox1" runat="server"
</telerik:RadTextBox> 
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> 
    </div> 
     
    </form> 
</body> 
</html> 
 

C#:
using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
 
namespace TESTAPP 
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            RadTextBox1.Text = "aaabbbccc"
        } 
 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            string s = RadTextBox1.Text; 
        } 
    } 
 

When I change the value aaabbbccc to something else and click the button, the value of RadTextBox1.Text is still aaabbbccc!


2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 04 Dec 2008, 01:15 PM
Hi,

You need to set the value only on initial load:

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        RadTextBox1.Text = "aaabbbccc";
    }
}

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
NMA
Top achievements
Rank 1
answered on 04 Dec 2008, 01:31 PM
Thanks Vlad.

I guess I am sleepwalking (or sleepcoding) for not seeing this :)))))
Tags
General Discussions
Asked by
NMA
Top achievements
Rank 1
Answers by
Vlad
Telerik team
NMA
Top achievements
Rank 1
Share this question
or