I am getting an error with the viewstate. I need to do some stuff in the code behind of the child radwindow prior to closing it. Then I need to do some other tasks on the parent form. After I click the close window of the child radwindow and then click the button on the parent form I get the message "Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request. " I am new to this and have read the __doPostBack, but am not sure if I need that or where to start. I would appreciate any insight. I have supplied the code below. Thanks.
John
parentForm
aspx
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Untitled Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<telerik:radscriptmanager id="ScriptManager1" runat="server" enabletheming="True"></telerik:radscriptmanager>
<div>
</div>
<telerik:radwindowmanager id="RadWindowManager1" runat="server" behavior="Default"
initialbehavior="None" left="" top=""></telerik:radwindowmanager>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</
body>
</
html>
code behind
Public
Partial Class frmMDI
Inherits System.Web.UI.Page
Dim newWindow1 As New Telerik.Web.UI.RadWindow()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Try
'create child modal window
newWindow1.Behaviors = Telerik.Web.UI.WindowBehaviors.Move
newWindow1.Height =
"320"
newWindow1.Width =
"422"
newWindow1.Title =
"Child Window"
newWindow1.Modal =
True
newWindow1.VisibleTitlebar =
False
newWindow1.VisibleOnPageLoad =
True
newWindow1.NavigateUrl =
"frmChild.aspx"
newWindow1.Visible =
True
newWindow1.DestroyOnClose =
True
RadWindowManager1.Windows.Add(newWindow1)
Catch ex As Exception
Dim strEr As String = ex.ToString
End Try
Else
End If
End Sub
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'do some code behind
Button1.Text =
"Refreshed"
End Sub
End
Class
child form
aspx
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Child Window</title>
<script type="text/javascript">
function get_RadWindow() //verify that it's a radWindow
{
var oWindow = null;
if (window.radWindow)
{ oWindow = window.radWindow; }
else if (window.frameElement.radWindow)
{ oWindow = window.frameElement.radWindow; }
return oWindow;
}
function JustClose()
{
get_RadWindow().Close();
}
</script>
</
head>
<
body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableTheming="True">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">
<asp:Button ID="Button1" runat="server" Text="Close Window" /></telerik:RadAjaxPanel>
</form>
</
body>
</
html>
code behind
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'do some code behind
RadAjaxManager1.ResponseScripts.Add(
"JustClose()")
End Sub