RadWindow as MessageBox

2 posts, 0 answers
  1. Jagat
    Jagat avatar
    151 posts
    Member since:
    Jan 2011

    Posted 26 Jun 2012 Link to this post

    I'm looking for a way to use RadWindow as a MessageBox/Modal popup. Basically I need to send a message to the Window from any of the pages in the application and display the message.  

    Example: DisplayMessage("123 records have been successfully updated.")

    Appreciate if you can share code sample!!


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Jun 2012 Link to this post

    Hi Jagat,

    I suppose you want to return value from one page to the other using RadWindow. Following is the sample code that I tried based on your scenario.

    DefaultCS Page:

    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" OnClientClose="OnClientClose"
            ReloadOnShow="true" runat="server" Skin="Sunset" EnableShadow="true">
            <Windows>
                <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close"  Modal="true"
                    NavigateUrl="Dialog1.aspx">
                </telerik:RadWindow>
            </Windows>
    </
    telerik:RadWindowManager>

    <
    asp:Button ID="Button1" runat="server" Text="Window" OnClientClick="openWin(); return false;" />

    <
    div id="order" >
                <!---->
    </
    div>

    JS:
    <script type="text/javascript">
        function openWin() {
            var oWnd = radopen("Dialog1.aspx", "RadWindow1");
        }
        function OnClientClose(oWnd, args) {
            var arg = args.get_argument();
            if (arg) {
                var cityName = arg.cityName;
                var seldate = arg.selDate;
                $get("order").innerHTML = "You choose <strong>" + cityName + "</strong> on <strong>" + seldate + "</strong>";
            }
        }
    </script>

    Dialog Page:

    ASPX:
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" OnClientClick="returnToParent(); return false;" runat="server" Text="Submit" />

    JS:
    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
        function returnToParent() {
            var oArg = new Object();
            oArg.cityName = document.getElementById("TextBox1").value;
            oArg.selDate = document.getElementById("TextBox2").value;
            var oWnd = GetRadWindow();
            if (oArg.selDate && oArg.cityName) {
                oWnd.close(oArg);
            }
            else {
                alert("Please fill both fields");
            }
        }
    </script>

    Please take a look into this demo for more information.

    Hope this helps.

    Thanks,
    Princy.
Back to Top