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

trigger radwindow from postback

1 Answer 218 Views
This is a migrated thread and some comments may be shown as answers.
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
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.
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<head id="Head1" runat="server">
<body class="BODY">
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server" PreserveClientState="false">
                        <telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="false" runat="server" NavigateUrl="">
                <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" />
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 = "";
       win.VisibleOnPageLoad = true;
   protected void btnShowNewWindowUsingRadWindowClientAPI_Click(object sender, EventArgs e)
       String script = "function _openNewWindow(){{ " +
            "Sys.Application.remove_load(_openNewWindow);" +
                " oMgr = GetRadWindowManager();" +
                "var oWnd = radopen('', null);" +
                " oWnd.set_title('NEW TITLE');" +
                "}};" +
       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');" +
              "}};" +
       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
Asked by
Top achievements
Rank 1
Answers by
Petio Petkov
Telerik team
Share this question