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

Reading the viewstate object.

2 Answers 200 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Wim van der Linden
Top achievements
Rank 1
Wim van der Linden asked on 15 Oct 2009, 01:50 PM
Hello,

I've got a problem with the viewstate object, when for example using a textbox within the xmlhttppanel.
I've read the following in the help documentation.

"Callback - When a client callback is used, the server Page does not go through its whole lifecycle, but only a small part of it. The client state is not updated, and it is not sent back to the client-side. When Callbacks are used, a POST request is made from the client to the server, and the values of all FORM fields, such as hidden fields (!including the view state field!) are sent to the server. When the view state is large, this could mean increased overhead. On the other hand, no extra files are needed to use this mode (unlike when using a WebService). "

However when the callback gets executed my pageload gets triggered, but I do not get the viewstate data.

What should I do to retrieve the data from the viewstate field?

kind regards,
Wim

2 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 20 Oct 2009, 07:39 AM
Hi Wim,

I am sorry but I cannot fully understand your scenario. Please take a look at the following project, where I store a Value (entered from a TextBox) in the ViewState and when a callback is initialized on the XmlHttpPanel the value is shown in the TextBox hosted inside the Panel.

.aspx
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadScriptBlock runat="server">
 
        <script type="text/javascript">
            function SetValue()
            {
                var panel = $find("<%=XmlPanel1.ClientID %>");
                panel.set_value("value");
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:TextBox ID="txtViewState" runat="server" Text="[Initial Text]">
    </asp:TextBox><asp:Button ID="Button1" runat="server" Text="Store Some Value in ViewState"
        OnClick="Button1_OnClick" />
    <br />
    <asp:Button ID="btnMakePostback" runat="server" Text="Make Postback" />
    <br />
    <br />
    <input type="button" value="Retrieve Value From ViewState" onclick="SetValue(); return false;" />
    <br />
    <br />
    <telerik:RadXmlHttpPanel ID="XmlPanel1" runat="server" OnServiceRequest="XmlPanel1_ServiceRequest"
        EnableClientScriptEvaluation="true">
        <asp:TextBox ID="TextBox1" runat="server" Text="[Empty Text]"></asp:TextBox>
    </telerik:RadXmlHttpPanel>
    </form>
</body>
</html>

.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsCallback)
        {
            TextBox1.Text = (string)ViewState["SomeValue"];
        }
    }
 
    protected void Button1_OnClick(object sender, EventArgs e)
    {
        ViewState["SomeValue"] = txtViewState.Text;
    }
 
    protected void XmlPanel1_ServiceRequest(object sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
    {
    }
}
 
Please provide more information and (possibly) a running project where the problem with accessing the ViewState can be observed.


Best wishes,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wim van der Linden
Top achievements
Rank 1
answered on 20 Oct 2009, 08:15 AM
Hello Pero,

Thank you for the answer but I think I've been looking at the problem the wrong way.
After reading things about the viewstate I realised it has nothing to do with the viewstate.

The point was that I had a textbox within the xmlhttppanel.
when I modify it's text I didn't get the textchanged event on the serverside.

But I now realise the control is not ment for this.

thank you for your answer and sorry for taking up your time.

kind regards
Wim.
Tags
XmlHttpPanel
Asked by
Wim van der Linden
Top achievements
Rank 1
Answers by
Pero
Telerik team
Wim van der Linden
Top achievements
Rank 1
Share this question
or