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

Lost TextBox Value in ServerSide RadXmlHttpPanel Event

2 Answers 92 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Hakan
Top achievements
Rank 1
Hakan asked on 03 Jul 2010, 01:32 PM
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;  
        RadGrid1.DataBind();  
 
    } 

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

<
telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server"  OnServiceRequest="XmlHttpPanel_ServiceRequest" 
                RenderMode="Block">  
     <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> 
    <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel2" runat="server" EnableClientScriptEvaluation="true"  OnServiceRequest="XmlHttpPanel_ServiceRequest2" 
                RenderMode="Block">  
    <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%"  > 
                    <Columns> 
                        <telerik:GridBoundColumn DataField="Id"  Visible="false">  
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn HeaderText="Name" DataField="Header" UniqueName="Header"  > 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn HeaderText="Address" DataField="ShortDescription" UniqueName="ShortDescription">  
                        </telerik:GridBoundColumn> 
                    </Columns> 
                </MasterTableView> 
                <PagerStyle Mode="NumericPages" PageButtonCount="5" /> 
                <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" ClientEvents-OnRowSelected="rowSelected">  
                </ClientSettings> 
        </telerik:RadGrid> 
    </telerik:RadXmlHttpPanel> 

2 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 07 Jul 2010, 11:59 AM
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,
Pero
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
0
piotre6
Top achievements
Rank 1
answered on 10 Oct 2011, 08:30 AM
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:
EnableClientScriptEvaluation="true"
in your XmlHttpPanel.
Tags
XmlHttpPanel
Asked by
Hakan
Top achievements
Rank 1
Answers by
Pero
Telerik team
piotre6
Top achievements
Rank 1
Share this question
or