RadTextBox is not getting updated with oldvalue

2 posts, 0 answers
  1. Arvind
    Arvind avatar
    40 posts
    Member since:
    Sep 2010

    Posted 31 Jan 2011 Link to this post


    If user changes the name in the textbox user is shown with confirm box  ok , cancel
    if user clicks on ok edited name need to be changed
    if user clicks on cancel old name need to be repopulated 
    Here i am facing problem in
    1. repopulating the textbox with oldvalue
    2.these textbox is placed in textbox when ever page is getting loaded it is showing confirm box
     

    function
    TextChanged(Sender,EventArgs)
       {
     
           var sSave;
                       
                       var Nametext = $find('<%= radtxtName.ClientID  %>');
     
                       sSave = confirm("Name is changed");
                       alert(sSave);
              if (sSave == true)
              {
                  
                  var NewValue = EventArgs.get_newValue();
                  Nametext .set_value(NewValue);
                   
              }
              else   {
     
                  var oldValue = EventArgs.get_oldValue();
                  Nametext .set_value(oldValue);
                 
              }
              
           
      }
    <telerik:RadTextBox ID="radtxtName" runat="server" >
       <ClientEvents OnValueChanged="TextChanged" />
        </telerik:RadTextBox>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Feb 2011 Link to this post

    Hello Aravid,

    I have also faced the same issue and modified the code as below. Give a try with this code.

    javascript:
    <script type="text/javascript">
    flag = 0;
    function TextChanged(Sender, EventArgs) {
            if (flag == 1)
            {
                flag = 0;
                return;
            }
            var sSave;
            Nametext = $find('<%= radtxtName.ClientID  %>');
            sSave = confirm("Name is changed");
            if (sSave == true) {
                var NewValue = EventArgs.get_newValue();
                Nametext.set_value(NewValue);
     
            }
            else
           {
                flag = 1;
                value = EventArgs.get_oldValue();
                Nametext.set_value(value);
            }
        }
    </script>

    Thanks,
    Shinu.
Back to Top