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

Closing a RadWindow from Usercontrol Button click event

3 Answers 183 Views
Window
This is a migrated thread and some comments may be shown as answers.
SUBBU
Top achievements
Rank 1
SUBBU asked on 06 Mar 2013, 01:01 PM
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);
  
}

3 Answers, 1 is accepted

Sort by
0
MasterChiefMasterChef
Top achievements
Rank 2
answered on 06 Mar 2013, 02:03 PM
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
0
SUBBU
Top achievements
Rank 1
answered on 06 Mar 2013, 03:33 PM
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.
0
rdmptn
Top achievements
Rank 1
answered on 07 Mar 2013, 03:17 PM
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.
Tags
Window
Asked by
SUBBU
Top achievements
Rank 1
Answers by
MasterChiefMasterChef
Top achievements
Rank 2
SUBBU
Top achievements
Rank 1
rdmptn
Top achievements
Rank 1
Share this question
or