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

trigger radwindow from postback

1 Answer 252 Views
Window
This is a migrated thread and some comments may be shown as answers.
Clayton
Top achievements
Rank 1
Clayton asked on 20 Jul 2010, 06:09 AM
Alright, I've found a few posts on how to trigger a RadWindow (such as RadAlert, etc) from a server-side postback, but NONE work when the control generating the postback is 'ajaxified'. This is a huge letdown, since I had wanted to use radwindows for displaying exceptions,etc to the user.

Here are some of the notable posts I've found:

this, and this

A year ago I was using the Ajax Toolkit, and relied on the "Modal Popup" for this same thing. It worked wonderfully. I could create a popup with a label, and set the label text on exception and call 'myPopup.visible=true;' and guarantee that it would show up for the user regardless of whether or not the postback control was ajaxified. Is it possible to replicate this functionality with the radwindow stuff?

1 Answer, 1 is accepted

Sort by
0
Accepted
Petio Petkov
Telerik team
answered on 20 Jul 2010, 12:17 PM
Hi Clayton,

You can use RadWindow's VisibleOnPageLoad property to show/hide RadWindows via AJAX/Postback. Keep in mind that if show RadWindow via AJAX you should update RadWindowManager(e.g. add RadWindowManager in UpdatePanel)

The radAlert can be shown only via the RadWindowManager's radalert client-side method. If you want to show a radalert after AJAX you should use ScriptManager.RegisterStartupScript to run a script, which will open a radAlert once the AJAX call is finished.

The code below illustrates several ways of creating RadWindows/radAlerts - please choose the one which is most suitable for your needs.
ASPX:
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head id="Head1" runat="server">
</head>
<body class="BODY">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server" PreserveClientState="false">
                    <Windows>
                        <telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="false" runat="server" NavigateUrl="http://www.google.com">
                        </telerik:RadWindow>
                    </Windows>
                </telerik:RadWindowManager>
                <asp:Button ID="btnShowAlreadyCreatedWindow" runat="server" OnClick="btnShowAlreadyCreatedWindow_Click" Text="AJAX - ShowAlreadyCreatedWindow" />
                <asp:Button ID="btnShowNewWindow" runat="server" OnClick="btnShowNewWindow_Click" Text="AJAX - ShowNewWindow" />
                <asp:Button ID="btnShowNewWindowUsingRadWindowClientAPI" runat="server" OnClick="btnShowNewWindowUsingRadWindowClientAPI_Click" Text="AJAX - ShowNewWindowUsingRadWindowClientAPI" />
                <asp:Button ID="btnShowRadAlert" runat="server" OnClick="btnShowRadAlert_Click" Text="AJAX - ShowRadAlert" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>
Codebehind:
protected void btnShowAlreadyCreatedWindow_Click(object sender, EventArgs e)
   {
       RadWindow1.VisibleOnPageLoad = true;
   }
   protected void btnShowNewWindow_Click(object sender, EventArgs e)
   {
       RadWindow win = new RadWindow();
       win.ID = "NEWRADWINDOW";
       win.NavigateUrl = "http://www.microsoft.com";
       win.VisibleOnPageLoad = true;
       RadWindowManager1.Windows.Add(win);
   }
   protected void btnShowNewWindowUsingRadWindowClientAPI_Click(object sender, EventArgs e)
   {
       String script = "function _openNewWindow(){{ " +
            "Sys.Application.remove_load(_openNewWindow);" +
                " oMgr = GetRadWindowManager();" +
                "var oWnd = radopen('http://www.yahoo.com', null);" +
                " oWnd.set_title('NEW TITLE');" +
                "}};" +
            "Sys.Application.add_load(_openNewWindow);";
       ScriptManager.RegisterStartupScript(this, this.GetType(), "openNewWindow", script, true);
   }
   protected void btnShowRadAlert_Click(object sender, EventArgs e)
   {
       String script = "function _openRadAlert(){{ " +
          "Sys.Application.remove_load(_openRadAlert);" +
              " radalert('<h3>SOME TEXT</h3>', null, null, 'Result');" +
              "}};" +
          "Sys.Application.add_load(_openRadAlert);";
       ScriptManager.RegisterStartupScript(this, this.GetType(), "openRadAlert", script, true);
   }

Let us know if you have any other questions.

Kind regards,
Petio Petkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Clayton
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Share this question
or