Lost TextBox Value in ServerSide RadXmlHttpPanel Event

3 posts, 0 answers
  1. Hakan
    Hakan avatar
    12 posts
    Member since:
    Jul 2010

    Posted 03 Jul 2010 Link to this post

    I couldnt get TextBox value Which is placed inside of the XmlHttpPanel.Why I lost value?
    There are no TextBox values XmlHttpPanel_ServiceRequest2 event,Values also set  XmlHttpPanel_ServiceRequest
    event.Just I can take values with js and panel.set_value but When I have a many TextBoxes this is problem.

    C Sharp Code

       protected void XmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)  
                string val = e.Value;  
                DataSet ds = db.dbRead("Select * from Doctors where Id=" + val + "");  
                TextBox1.Attributes.Add("Value", ds.Tables[0].Rows[0]["Header"].ToString());  
                TextBox1.Text = ds.Tables[0].Rows[0]["Header"].ToString();  
                TextBox2.Text = ds.Tables[0].Rows[0]["ShortDescription"].ToString();  
                TextBox3.Text = val;  
        protected void XmlHttpPanel_ServiceRequest2(object sender, RadXmlHttpPanelEventArgs e)  
            //Random numbers = new Random();  
            //int index = numbers.Next(1, 10);  
            int i = db.dbWrite("update doctors set Header='" + TextBox1.Text + "',ShortDescription='" + TextBox1.Text + "' where Id=" + TextBox1.Text + "");  
            RadGrid1.DataSource = LoadData();  
            RadGrid1.CurrentPageIndex = 0;  

    JS COde
    function rowSelected(sender, args) {  
                    var key = args.getDataKeyValue("Id");  
                    var panel = $find("<%=RadXmlHttpPanel1.ClientID %>");  
                function UpdateGrid() {  
                    var panel = $find("<%=RadXmlHttpPanel2.ClientID %>");  
                    panel.set_value("any value");  

    telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server"  OnServiceRequest="XmlHttpPanel_ServiceRequest" 
         <asp:Button ID="Button1" runat="server" Text="Update Record and Grid " OnClientClick="UpdateGrid();return false;"  /> 
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> 
            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> 
        <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel2" runat="server" EnableClientScriptEvaluation="true"  OnServiceRequest="XmlHttpPanel_ServiceRequest2" 
        <telerik:RadGrid ID="RadGrid1"  Skin="Hay"  OnNeedDataSource="RadGrid1_NeedDataSource" 
                    Width="370px" AllowSorting="True"   PageSize="10" AllowPaging="True" runat="server" 
                    AutoGenerateColumns="false" GridLines="None">  
                    <MasterTableView ClientDataKeyNames="Id" Width="100%"  > 
                            <telerik:GridBoundColumn DataField="Id"  Visible="false">  
                            <telerik:GridBoundColumn HeaderText="Name" DataField="Header" UniqueName="Header"  > 
                            <telerik:GridBoundColumn HeaderText="Address" DataField="ShortDescription" UniqueName="ShortDescription">  
                    <PagerStyle Mode="NumericPages" PageButtonCount="5" /> 
                    <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" ClientEvents-OnRowSelected="rowSelected">  
  2. Pero
    Pero avatar
    1156 posts

    Posted 07 Jul 2010 Link to this post

    Hi Hakan,

    The RadXmlHttpPanel uses ASP.NET client callbacks to retrieve its HTML from the server. The page does not go through its standard lifecycle - most importantly the ViewState is not loaded and saved. This means that, if you change a property of a server control, the new value will not be persisted. That's why the value of the TextBox is lost.

    More information about the RadXmlHttpPanel control can be found on our website: http://www.telerik.com/help/aspnet-ajax/radxmlhttppanel.html.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. piotre6
    piotre6 avatar
    18 posts
    Member since:
    Apr 2011

    Posted 10 Oct 2011 Link to this post

    If service is used to send data to server should l it work? i have another problem with xmlhttppanel. after server request all client side function sucha asremoving empty message on click is gone . Do you know what mayer be the reason ?

    I have found the solution myself. For those who have same problem,
    make sure you have:
    in your XmlHttpPanel.
Back to Top