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

RadWindow as MessageBox

1 Answer 369 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 26 Jun 2012, 07:22 PM
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!!


1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Jun 2012, 03:20 AM
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.
Tags
Window
Asked by
Jagat
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or