Opening RadWindow from the server

4 posts, 0 answers
  1. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 19 Oct 2011 Link to this post

    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
  2. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 19 Oct 2011 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Oct 2011 Link to this post

    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.
  5. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 21 Oct 2011 Link to this post

    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

Back to Top