Closing a RadWindow from Usercontrol Button click event

4 posts, 0 answers
  1. SUBBU
    SUBBU avatar
    10 posts
    Member since:
    Apr 2012

    Posted 06 Mar 2013 Link to this post

    Hi,

    I have a set of links in one of the usercontrol. The same usercontrol contains two RadWindows. I am binding another usercontrol within the ContentTemplate section of RadWindow. When the user clicks on the link a radwindow should be opened. When the user clicks on the button that present in the radwindow, i need to perform some process and close the radwindow. Then show the second radwindow with a success message. I am unable to close the first radwindow from usercontrol button click event. How to achieve this?

    Thanks in advance.
    UserControl 1
    <script type="text/javascript">
    function closeAndOpen() {
            $find("<%= modalWindow.ClientID %>").close();
            $find("<%= confirmationWindow.ClientID %>").show()
        }
    </script>
    <div class="links">
                    <asp:LinkButton ID="changeProfile" runat="server" meta:resourcekey="changeUsername"
                        CssClass="fontUnderline linkFont noLink" CausesValidation="False" OnClick="changeProfile_Click"></asp:LinkButton>
                </div>
      
    <telerik:RadWindowManager ID="radWindowManager" runat="server" DestroyOnClose="false"
            EnableShadow="true" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true"
            Opacity="100">
            <Windows>
                <telerik:RadWindow ID="modalWindow" runat="server" Visible="false" VisibleOnPageLoad="true" VisibleStatusbar="false" Behaviors="None">
                    <ContentTemplate>
                        <uc:Profile ID="changeProfileControl" runat="server" Visible="false" />                    
                    </ContentTemplate>
                </telerik:RadWindow>
                <telerik:RadWindow ID="confirmationWindow" runat="server" Visible="false" VisibleOnPageLoad="true" VisibleStatusbar="false" Behaviors="None">
                    <ContentTemplate>
                        <uc:successmessage ID="confirmation" runat="server" />
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
      
    UserControl 2:
      
    In my button click event I am registering the script
      
    Protected Button_Click()
    {
      
    //Do some process
      
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Testing Script", "closeAndOpen();", true);
      
    }
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 06 Mar 2013 Link to this post

    Hi SUBBU,

    You're sure calling the right methods to hide the RadWindow, but it may be an issue with the fact that the button is removing the element it is inside of. Take a look at this thread with a similar issue to your; it could provide you with a good bit of information on RadWindow manipulation:
    http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/radwindow-close-button.aspx

    Good luck,
    Master Chief
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. SUBBU
    SUBBU avatar
    10 posts
    Member since:
    Apr 2012

    Posted 06 Mar 2013 Link to this post

    Hi,

    Thanks for your reply. I think the links you have shared mainly deal with radwindow out of box close. In my case the javascript gets invoked from the asp.net button click but the radwindow which i am trying to find using "$find" gives null. I have placed my javascript in the parent usercontrol. Even though it shows null. Any help will be appreciated.
  5. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 07 Mar 2013 Link to this post

    Just register your scripts to run in time, you need the Sys.Application.Load event. This is explained here: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx. A sticky thread just a few rows above :) Your problem is that the objects are not initialized when the script runs, so $find() returns null.

    ScriptManager.RegisterStartupScript(this, this.GetType(), "Testing Script", "Sys.Application.add_load(closeAndOpen);", true);

    is the starting point. You need to remove this Load handler when it is executed, and you should use that to open the first. The VIsibleOnPageLoad and VIsible properties of the RadWindows are not the best options in most cases.

    Remove the manager as well - user controls will create many instances, and you are using the ContentTemplate. Both of these scenarios should be avoided.
Back to Top