RadTextBox old value and new value

4 posts, 0 answers
  1. Veeru
    Veeru avatar
    3 posts
    Member since:
    May 2011

    Posted 16 Aug 2011 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Aug 2011 Link to this post

    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.
  3. Veeru
    Veeru avatar
    3 posts
    Member since:
    May 2011

    Posted 17 Aug 2011 Link to this post

    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.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2011 Link to this post

    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.
Back to Top