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

RadTextBox old value and new value

3 Answers 432 Views
Input
This is a migrated thread and some comments may be shown as answers.
Veeru
Top achievements
Rank 1
Veeru asked on 16 Aug 2011, 02:57 PM
Hi Team,

How read the RadTextBox old value and new value on button ClientClick event from JavaScript.

i tried below properties and methods, but all are giving the new values only.
var rtb = $find('radTxtName');
get_value(),  get_displayValue(), _initialValue, get_editValue(), get_textBoxValue().

please suggest me how read the RadTextBox old value which is loaded during page load.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Aug 2011, 07:35 AM
Hello Veeru,

I am not quite sure about your requirement. You can access the RadTextBox as shown below.
Javascript:
<script type="text/javascript">
function OnValueChanged(sender, args)
{
var Nametext = $find('<%= radtxtName.ClientID%>');
var value=args.get_oldValue();
}
</script>

Also check the following help documentation which explains the same.
RadTextBox Client Object.

Thanks,
Princy.
0
Veeru
Top achievements
Rank 1
answered on 17 Aug 2011, 08:14 AM
Hi Princy,

             Thanks for your response.
I don't want to use the OnValueChanged event for RadTextBox.

My requirement is
I have a page with 3 RadTextBox controls and a ASP button.
On page load i will assign the values to those 3 textboxes.
On button ClientClick event i have to validate whether user has changed any RadTextBox value?
This is my requirement.

So i have to read the RadTextBox old value which i assigned during page load.
Please let me know how to get that.


Thanks,
Veeru.
0
Princy
Top achievements
Rank 2
answered on 18 Aug 2011, 03:34 PM
Hello Veeru,

I am still not quite sure about your requirement.One approach is that you can use OnLoad ClientEvent. In both approaches we are using the same RadTextBox and Button.
Method1:
aspx:
<telerik:RadTextBox ID="radtxtName" runat="server">
   <ClientEvents OnLoad="onload" />
</telerik:RadTextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="btnclick();"/>
JS:
function onload(sender,args)
{
 var Nametext = $find('<%= radtxtbox1.ClientID%>');
 value1=Nametext.get_value();
}
 
function btnclick()
{
  var Nametext = $find('<%= radtxtbox1.ClientID%>');
  var TextBox = Nametext.get_value();
  if(TextBox==value1)
    {
     alert("oldvalue");
    }
   else
    {
     alert("newvalue");
    }
}
Method2:
The other approach is that you can use the OnValueChanging Client Event.
JS:
function OnValueChanging(sender, args)
{
 flag=1;
}
function btnclick()
{
 if(flag==0)
{
 alert("oldvalue");
 flag=1;
}
 else
 {
 alert("newvalue");
 flag=0;
 }
}

Thanks,
Princy.
Tags
Input
Asked by
Veeru
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Veeru
Top achievements
Rank 1
Share this question
or