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

Opening RadWindow from the server

3 Answers 55 Views
Window
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 2
Erik asked on 19 Oct 2011, 08:51 PM
Hello,

I read that we can also add a RadWindow now like this:
Dim window1 As New Telerik.Web.UI.RadWindow
With window1
    .VisibleOnPageLoad = True
    .ID = "UniqueDialogWindowID"
    .Width = 450
    .Height = 550
    .AutoSize = True
    .Modal = True
    .VisibleStatusbar = False
    .ContentContainer.Controls.Add(New LiteralControl("Dynamic loaded control"))
    .Title = "Test"
End With
Page.Controls.Add(window1)

And this workes fine (when you also load this in init on postback of course)

The closing I do on the Page_PreRender, by removing the RadWindow from the controls collection.

In the AJAXed version of my application however, this couses problems. The Windows is loaded and displayed, but afeter the close (server side, remove RadWindow control in PreRender thus) and ReOpening, the control is loaded but not shown...

Is this not correct use of functionality?

Erik

3 Answers, 1 is accepted

Sort by
0
Erik
Top achievements
Rank 2
answered on 19 Oct 2011, 09:33 PM
Well, I've been at it all day, implemented 10+ scenario's, but no effect. The solutions provided here do NOT work at all:
http://www.telerik.com/support/kb/aspnet-ajax/window/calling-radalert-from-codebehind.aspx
or here: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx
and others.

Again: scenario: I want to open a RadWindow on postback afeter pressing a button on server side. Getting this to work would be a big happening over here! :-) no pressure, must be done by monday, so hopefully it is RadSupport because it is not RadWindow... :-)

Thanks in advance for any feedback.

Erik
0
Princy
Top achievements
Rank 1
answered on 20 Oct 2011, 06:53 AM
Hello Erik,

I have tried to reproduce the issue but it is no avail. Here is the code.

ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="open in btnclick.aspx.cs" Inherits="radwindow_open_in_btnclick" %>
<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="scriptmngr" runat="server">
    </asp:ScriptManager>
    <asp:Button ID="Button1" runat="server" Text="Open" onclick="Button1_Click" />
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <Windows>
    <telerik:RadWindow ID="RadWindow1" runat="server">
    </telerik:RadWindow>
    </Windows>
    </telerik:RadWindowManager>
   </div>
   </form>
</body>
</html>

VB:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
    Dim script As String = "function f(){$find(""" + RadWindow1.ClientID & """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
    ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "key", script, True)
End Sub
                       OR
 
Protected Sub Button1_Click(sender As Object, e As EventArgs)
        RadWindow1.VisibleOnPageLoad = True
    RadWindowManager1.Windows.Add(RadWindow1)
End Sub

Thanks,
Princy.
0
Erik
Top achievements
Rank 2
answered on 21 Oct 2011, 06:01 PM
Hello Princy,

Yes, that also works with me. But your example is not using AJAX or Dynamic control loading and dynamic window loading.

I got it to work. I was getting a low level error (in the httpApplication) many times during this testing:
"Value cannot be null"  "Parameter name: exception"

Today I was testing some layout and deleted a server control (textbox) and did a postback. This, of course, thows an error, but the same error as mentioned above. So, clearly the problem causing the error is that viewstate has a problem after postback because it expects a control that is not there.

What I now do:
I ALWAYS create a radwindow in the init (in my case the dynamically loaded usercontrol) but I'm keeping the RadWindow.
VisibleOnPageLoad = False. This is important because otherwise teh above error pops up and no dialog is diaplayed and AJAX is FUBAR.

When i want to load a Window (dialog thus) i only load the dialog control into the Window content (RadWindow.ContentContainer.Controls.Add) and set the RadWindow.VisibleOnPageLoad = True. This will show the dialog after postback and keeps on diaplaying it (because the dialog can have postbacks aswell). When i want to close the dialog, a button in the dialog (that is out of the updatepanel in the dialog) is pressed, the postback on the server only does RadWindow.
VisibleOnPageLoad = False and the dialog is hidden on postback.

This seems to work.


Thanks, 

Erik

Tags
Window
Asked by
Erik
Top achievements
Rank 2
Answers by
Erik
Top achievements
Rank 2
Princy
Top achievements
Rank 1
Share this question
or