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

Viewstate lost on parent window when radWindow closed

3 Answers 178 Views
Window
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 01 Mar 2013, 04:57 AM
I have hit the following scenario which I have managed to strip out in to a small example.  I have a radWindow that is opening a new aspx page.  On that page the user needs to cause a number of postbacks; after a certain number of postbacks are made and the window is closed by the user the parent page loses all state. Any subsequent postback on the parent page results in all dropdowns losing their data, it also sometimes occurs with textbox values.  This should explain it better:

This is the parent page:
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function openRadWindow() {
        var oWnd = radopen("/parts/test.aspx", "RadWindow1");     
        oWnd.setSize(850, 700);
        oWnd.center();
    }
        </script>
</head>
<body>
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
       <asp:DropDownList ID="lstComponent" runat="server" />
        <asp:Button ID="btnReload" runat="server" OnClick="btnReload_Click" />
        <asp:Button ID="btnAddNew" runat="server" Text="Add New" OnClientClick="openRadWindow('', '', '', ''); return false;" CssClass="button small green" />
    <telerik:RadWindowManager ShowContentDuringLoad="false" EnableShadow="true" InitialBehaviors="Maximize"
    ID="RadWindowManager1" runat="server" Behaviors="Close" >
    </telerik:RadWindowManager>
    </form>
</body>
</html>

This is the code behind:
protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               lstComponent.Items.Clear();
               lstComponent.Items.Insert(0, new ListItem(QA.BLL.Common.Const.please_select, String.Empty));
           }
       }

This is the page that is opened:
<!DOCTYPE html>
 
<head runat="server">
    <title></title>
     <script type="text/javascript">
         function CloseAndRebind(args) {
             //GetRadWindow().BrowserWindow.refreshGrid(args);
             GetRadWindow().close();
         }
 
         function GetRadWindow() {
             var oWindow = null;
             if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
             else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
 
             return oWindow;
         }
 
         function CancelEdit() {
             GetRadWindow().close();
         }
 
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <asp:Button ID="Button1" runat="server" Text="Nothing" OnClick="Button1_Click" />
    <asp:Button ID="btnTest" runat="server" OnClick="btnTest_Click" />
    </div>
    </form>
</body>
</html>

And its code behind:

public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void btnTest_Click(object sender, EventArgs e)
        {
            int test = 1;
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndRebind('Rebind');", true);
        }
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            btnTest.Text = DateTime.Now.ToShortTimeString();
        }
    }

Now to make the issue occur perform the following steps:
  1.  press the btnAddNew button on the parent page to make the window appear
  2. on the window press Button1 a number of times (x10)
  3. Press the btnTest button to close the window
  4. Press the btnReload button on the parent page to force a postback
  5. The option that had been added to the dropdown is gone.

This is a simplistic example but my parent page in my actual website has a number of dropdown controls all of which lose their state.

I am using version 2012.1.215.40. 

Thanks,
Richard

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Mar 2013, 12:34 PM
Hello Richard,

There isn't a reason for this behaviour in the RadWindow, yet I performed the suggested test and things worked as expected with me. You can find attached the test pages and a video from the test where everything seems to be in order.

What I suspect the problem is is a session expiration. In a more complex page generating 10 postbacks may take time and thus the main form may have expired on the server.

The RadWindow is merely an iframe that hosts the content page, so it does not affect the viewstate or session by itself.


All the best,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Richard
Top achievements
Rank 1
answered on 12 Mar 2013, 07:52 PM
I have realised where the issue is occuring.  My project has the sessionstate being saved on the server side.  By the time my radWindow has had 10 postbacks the viewstate of the calling page has been lost.  To get round it in this issue I added <sessionPageState historySize="40"/> in the web.config.  This now allows 40 postbacks on the radWindow before the call on the parent page is lost.

Is there any advice around this as keeping the viewstate on the page is not possible due to the size it becomes?
0
Marin Bratanov
Telerik team
answered on 14 Mar 2013, 11:40 AM
Hi Richard,

This behaviour does not stem from the RadWindow, but from the browser (because the page in the RadWindow is essentially loaded in an iframe) and from the framework. How the case is solved should be determined by the developer according to the specific case (e.g. disabling viewstate for a page that does not use it, e.g. the content page).

Greetings,
Marin Bratanov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Richard
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Richard
Top achievements
Rank 1
Share this question
or