I have a situation where we are getting an error loading viewstate. The setup (code below) is that we have a page, using a master page. On the master page we have a radwindowmanager. That master page plugs 2 windows into its list that are common to all pages. Inside our specific content pages, we have dynamic code that reads an xml file and uses that info to add additional windows to the radwindowmanager. In this way, the master page handles making global windows available (like Help, Settings, etc.) and each content page adds whatever windows it needs to that.
Anyway, in those same content pages we also have ajaxpanels containing things like calendar controls, grids, and things like that. What I've found is that after adding all the dynamic window code, using the controls in the ajaxpanel (like going to the next month on a calendar) causes the viewstate loading error.
What's the best way to correct this problem and also follow good design for all pages that do this?
Here's the .cs for the content page that shows the windows being built dynamically. The relevant stuff is the SetupWindows method:
We'll have many pages that take this approach of dynamic window instantiation, plugged into master page radwindowmanager, and multiple ajaxpanels on the content page doing "stuff."
Thx.
Anyway, in those same content pages we also have ajaxpanels containing things like calendar controls, grids, and things like that. What I've found is that after adding all the dynamic window code, using the controls in the ajaxpanel (like going to the next month on a calendar) causes the viewstate loading error.
What's the best way to correct this problem and also follow good design for all pages that do this?
Here's the .cs for the content page that shows the windows being built dynamically. The relevant stuff is the SetupWindows method:
using System; |
using System.Data; |
using System.Configuration; |
using System.Collections; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Web.UI.HtmlControls; |
using Sample.Schedule.Views; |
using Microsoft.Practices.ObjectBuilder; |
using Telerik.Web.UI; |
using Sample.CommonShared; |
using Sample.Messaging.Interface; |
namespace Sample.Schedule.Views |
{ |
public partial class ScheduleDefault : Microsoft.Practices.CompositeWeb.Web.UI.Page, IDefaultView |
{ |
private DefaultViewPresenter _presenter; |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!this.IsPostBack) |
{ |
this._presenter.OnViewInitialized(); |
SetupWindows(); |
} |
this._presenter.OnViewLoaded(); |
} |
[CreateNew] |
public DefaultViewPresenter Presenter |
{ |
get |
{ |
return this._presenter; |
} |
set |
{ |
if (value == null) |
throw new ArgumentNullException("value"); |
this._presenter = value; |
this._presenter.View = this; |
} |
} |
private void SetupWindows() |
{ |
RadWindowManager mgr = this.Master.FindControl("RadWindowManagerMaster") as RadWindowManager; |
if (null == mgr) |
throw new Exception("Contacts : RadWindowManager not found"); |
TypedDialog tds = new TypedDialog(); |
tds.ReadXml(Server.MapPath(this._presenter.msg.GetMessage("schedule_dialogxml"))); |
RadWindow thewin = new RadWindow(); |
for (int i = 0; i < tds.window.Count; i++) |
{ |
thewin.NavigateUrl = tds.window[i].navigateurl; |
thewin.ID = tds.window[i].id; |
thewin.VisibleOnPageLoad = false; |
thewin.Width = tds.window[i].width; |
thewin.Height = tds.window[i].height; |
thewin.EnableEmbeddedSkins = (tds.window[i].enableembeddedskins == "true"); |
thewin.Skin = tds.window[i].skin; |
if (string.Empty != tds.window[i].onclientclose) thewin.OnClientClose = tds.window[i].onclientclose; |
if ("true" == tds.window[i].ismodal) thewin.Modal = true; |
thewin.VisibleStatusbar = false; |
mgr.Windows.Add(thewin); |
thewin = new RadWindow(); |
} |
thewin.Dispose(); |
} |
} |
} |
...and here's the content page aspx file:
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="Sample.Schedule.Views.ScheduleDefault" |
Title="Default" MasterPageFile="~/Shared/DefaultMaster.master" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Register src="../RecentDeployments.ascx" tagname="RecentDeployments" tagprefix="uc1" %> |
<%@ Register src="../ScheduleCalendar.ascx" tagname="ScheduleCalendar" tagprefix="uc2" %> |
<asp:Content ID="content" ContentPlaceHolderID="DefaultContent" Runat="Server"> |
<link href="../Css/Schedule/Schedule.css" rel="stylesheet" type="text/css" /> |
<link href="../Css/UserControls/RecentDeployments.css" rel="stylesheet" type="text/css" /> |
<link href="../Css/UserControls/ScheduleCalendar.css" rel="stylesheet" type="text/css" /> |
<telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" Skin="Sample" EnableEmbeddedSkins="false" DecoratedControls="All" /> |
<script type="text/javascript"> |
//<![CDATA[ |
function showGetStarted() { |
var oM = GetRadWindowManager(); |
var oW = oM.GetWindowByName("wndDeploy"); |
oW.Show(); |
} |
function showAddContacts() { |
var oM = GetRadWindowManager(); |
var oW = oM.GetWindowByName("wndAddContacts"); |
oW.Show(); |
} |
function showUploadContacts() { |
var oM = GetRadWindowManager(); |
var oW = oM.GetWindowByName("wndUploadContacts"); |
oW.Show(); |
} |
function showEditContacts() { |
var oM = GetRadWindowManager(); |
var oW = oM.GetWindowByName("wndEditContacts"); |
oW.Show(); |
} |
function OnClientClose(radWindow) { |
//TODO window.location.href = window.location.href; |
} |
//]]> |
</script> |
<div id="contentpage"> |
<div class="schedule_fullwidth marginbottom-30"> |
<div class="schedule_leftpod"> |
<h3><asp:Label ID="lblDeploy" runat="server" Text="<%$ Resources:WebResources, dash_deployer_lbldeploy %>"/></h3> |
<h4>Get started Now</h4> |
<p> |
<asp:Label ID="lblGetStartedNow" runat="server" Text="<%$ Resources:WebResources, dash_deployer_lblgetstartednow %>"/><br /> |
<asp:Button ID="btnGetStarted" runat="server" OnClientClick="showGetStarted();return false;" Text="<%$ Resources:WebResources, button_getstarted %>" /> |
</p> |
<div class="schedule_leftpod_data"> |
<h4><asp:Label ID="lblContacts" runat="server" Text="<%$ Resources:WebResources, dash_deployer_lblcontacts %>"/></h4> |
<p> |
<asp:Label ID="lblContactsCount" runat="server" Text="<%$ Resources:WebResources, dash_deployer_lblcontactscount %>"/><br /> |
<asp:Label ID="lblGroupsCount" runat="server" Text="<%$ Resources:WebResources, dash_deployer_lblgroupscount %>"/> |
</p> |
</div> |
<div class="schedule_leftpod_icons"> |
<img src="../Images/deployer-dashboard-contact_male.png" alt="deployer-dashboard-contact_male" width="40" height="50"/> |
<img src="../Images/deployer-dashboard-contact_female.png" alt="deployer-dashboard-contact_female" width="40" height="50"/> |
</div> |
<div class="clear"></div> |
<p> |
<asp:Button ID="btnAddContacts" runat="server" OnClientClick="showAddContacts();return false;" Text="<%$ Resources:WebResources, button_addcontacts %>" /><br /> |
<asp:Button ID="btnEditContacts" runat="server" OnClientClick="showEditContacts();return false;" Text="<%$ Resources:WebResources, button_edit %>" /><br /> |
<asp:Button ID="btnUploadContacts" runat="server" OnClientClick="showUploadContacts();return false;" Text="<%$ Resources:WebResources, button_uploadcontacts %>" /><br /> |
</p> |
</div> |
<div class="schedule_rightpod"> |
<div class="schedule_rightpod_title"> |
<h3>Schedule</h3> |
</div> |
<div class="schedule_rightpod_description"> |
<p>August Stats: 23 Campaigns</p> |
</div> |
<div class="clear"></div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_brochure.png" alt="deployer-dashboard-icon_brochure" width="28" height="26"/><strong>BROCHURE<br />4 </strong>Brochures</p> |
</div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_email.png" alt="deployer-dashboard-icon_email" width="31" height="25"/><strong>EMAIL <br />5 </strong>Emails</p> |
</div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_ecard.png" alt="deployer-dashboard-icon_ecard" width="26" height="26"/><strong>ECARD <br />5 </strong>Emails</p> |
</div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_newsletter.png" alt="deployer-dashboard-icon_newsletter" width="24" height="27"/><strong>NEWSLETTER<br />6 </strong>Newsletters</p> |
</div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_coversplash.png" alt="deployer-dashboard-icon_coversplash" width="22" height="26"/><strong>COVERSPLASH<br />2 </strong>Surveys</p> |
</div> |
<div class="schedule_rightpod_headeritems"> |
<p><img src="../Images/deployer-dashboard-icon_form.png" alt="deployer-dashboard-icon_form" width="28" height="26"/><strong>FORM <br />4 </strong>Documents</p> |
</div> |
<div class="clear"></div> |
<div class="schedule_rightpod_calendar"> |
<telerik:RadAjaxPanel ID="ajaxpanelScheduleCalendar" runat="server" Height="375px" Width="660px" LoadingPanelID="ajaxloadingpanelScheduleCalendar"> |
<uc2:ScheduleCalendar ID="ScheduleCalendar1" runat="server" width="660" height="375" /> |
</telerik:RadAjaxPanel> |
</div> |
</div> |
</div> |
<div class="schedule_fullwidth"> |
</div> |
<telerik:RadAjaxLoadingPanel ID="ajaxloadingpanelScheduleCalendar" runat="server" Height="75px" |
Width="75px"> |
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' |
style="border: 0px;" /> |
</telerik:RadAjaxLoadingPanel> |
</asp:Content> |
We'll have many pages that take this approach of dynamic window instantiation, plugged into master page radwindowmanager, and multiple ajaxpanels on the content page doing "stuff."
Thx.