Event order when RadWindow closes

5 posts, 0 answers
  1. Jon
    Jon avatar
    3 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 Link to this post

    I open a RadWindow where the user provides data and then presses an OK button.  On postback, the data is processed and a status is generated.  I'm trying to show that status via a notification popup on the main page that opened the window.  

    I modified this example for my purposes so that I can pass the result back:  http://www.telerik.com/forums/refresh-radgrid-on-close-of-radwindow

    The problem is that the AjaxRequest event fires before the OK button click and so the status is unknown at this point.  Is there another scenario I can use to pass a value back server side?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 28 Aug 2014 in reply to Jon Link to this post

    Hi Jon,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadButton ID="rbtnOpenWin" runat="server" Text="Open">
    </telerik:RadButton>
    <asp:Label ID="lblNewValue" runat="server">
    </asp:Label>
    <telerik:RadWindow ID="rwindow" runat="server" OpenerElementID="rbtnOpenWin">
        <ContentTemplate>
            <asp:TextBox ID="txtValue" runat="server">
            </asp:TextBox>
            <asp:Button ID="btnOk" runat="server" Text="OK" OnClick="btnOk_Click" />
        </ContentTemplate>
    </telerik:RadWindow>

    C#:
    protected void btnOk_Click(object sender, EventArgs e)
    {
        lblNewValue.Text = txtValue.Text;
    }

    Please elaborate your requirement if it doesn't help.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    3 posts
    Member since:
    Aug 2014

    Posted 28 Aug 2014 in reply to Shinu Link to this post

    I'm trying to pass a value back to the main window and so I modified the code in the example I sited.  So the basic flow of events is:

    * RadWindow opens
    * User enters data and pushes OK which causes a PostBack and the window closes.
    * The window's OK button event produces the value that is then passed back which drives a Notification popup and what the AjaxManager causes to update.

    According to the code in the example I sited, I added this javascript and added OnClientClose="closeRadWindow" to the RadWindow.

           
    <script type="text/javascript"><br>           
    function closeRadWindow() {                
    $find(
    "<%= RadAjaxManager1.ClientID %>").ajaxRequest();
               }
    </script>

    I'm then using the AjaxManager to drive the notification popup.  The problem is that ajaxRequest fires before OKButton_Click.  Is there another way for me to pass a value back to the main window after the OK button has finished processing and force the window to fire an event?













  5. Jon
    Jon avatar
    3 posts
    Member since:
    Aug 2014

    Posted 28 Aug 2014 in reply to Jon Link to this post

    Ok...I see the real problem.  The window being opened is actually another page and so the controls and events are separated.  Is there a way to do it with the structure I have or do I need to move the controls on the other page into the window control?
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2014 in reply to Jon Link to this post

    Hi Jon,

    Please have  a look into the sample code snippet to achieve your scenario.

    Main Page ASPX:
    <telerik:RadTextBox ID="txtValueFromWindow" runat="server">
    </telerik:RadTextBox>
    <telerik:RadButton ID="rbtnOpenWin" runat="server" Text="Open" AutoPostBack="false"
        OnClientClicked="openWindow">
    </telerik:RadButton>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" OnClientClose="OnClientClose">
    </telerik:RadWindowManager>

    Main Page JavaScript:
    function openWindow() {
        radopen("WindoePage.aspx");
    }
    function OnClientClose(oWnd, args) {
        var arg = args.get_argument();
        if (arg) {
            var txtValue = arg.txtValue;
            $find("<%=txtValueFromWindow.ClientID%>").set_value(txtValue);
        }
    }

    Window Page ASPX:
    <telerik:RadTextBox ID="txtValue" runat="server">
    </telerik:RadTextBox>
    <telerik:RadButton ID="rbtnOk" runat="server" Text="OK" AutoPostBack="false" OnClientClicked="returnToParent">
    </telerik:RadButton>

    Window Page JavaScript:
    function returnToParent() {
        var oArg = new Object();
        oArg.txtValue = $find("<%=txtValue.ClientID %>").get_value();
        var oWnd = GetRadWindow();
        if (oArg.txtValue) {
            oWnd.close(oArg);
        }
    }
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow;
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
        return oWindow;
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017