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

Close RadWindow from Button inside Asp.Net Wizard Control

3 Answers 67 Views
Window
This is a migrated thread and some comments may be shown as answers.
Veer
Top achievements
Rank 1
Veer asked on 04 Feb 2014, 03:12 AM
Hello,

I am trying to close RadWindow from a button inside ASP.NET Wizard control step. but the javascript wont fire. 

<form id="form1" runat="server">
    <script type="text/javascript">
        function CloseAndRebind() {
            GetRadWindow().BrowserWindow.refreshGrids();
            GetRadWindow().close();
        }
 
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
 
            return oWindow;
        }
 
        function Cancel() {
            GetRadWindow().close();
        }
    </script>
    <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
    <div style="padding: 10px;">
         <div>
            <asp:Wizard ID="Wizard1" runat="server" BackColor="#EFF3FB" BorderColor="#B5C7DE"
                BorderWidth="1px" DisplaySideBar="False" OnFinishButtonClick="Wizard1_FinishButtonClick">
                <HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB" BorderStyle="Solid" BorderWidth="2px"
                    Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
                <NavigationButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid"
                    BorderWidth="1px" ForeColor="#284E98" />
                <StepStyle Font-Size="0.8em" ForeColor="#333333" />
                <HeaderTemplate>
                    <asp:Label ID="lblHeader" runat="server" />
                </HeaderTemplate>
                <WizardSteps>
                    <asp:WizardStep ID="WizardStep7" runat="server" Title="Thank you!" StepType="Complete">
                        <div style="padding: 10px;">
                            <h4>
                                Thank you!
                            </h4>
                                 
                                <telerik:RadButton ID="btnClose" runat="server" OnClientClick="CloseAndRebind();" Text="Go to main page" />
</div>
                    </asp:WizardStep>
                </WizardSteps>
            </asp:Wizard>
        </div>
    </div>
    </form>

3 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 05 Feb 2014, 01:03 PM
Hi,

RadButton only needs the name of the JavaScript function it has to fire when clicked: http://blogs.telerik.com/aspnet-ajax/posts/12-08-10/migrating-onclientclick-handlers-from-asp-button-to-telerik-s-asp-net-ajax-button.aspx.

Thus, here is how your code should look like:
<telerik:RadButton ID="btnClose" runat="server" OnClientClicked="CloseAndRebind" AutoPostBack="false" Text="Go to main page" />


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Veer
Top achievements
Rank 1
answered on 06 Feb 2014, 09:04 PM
Hello Marin,

Thanks for the reply, I tried your suggestion and it doesn't seem to be working, Atleast its not throwing any client side error or exception, However the RadWindow is not closing and the window stays open, Do you think a change is need in the script to work, since the button is inside the Wizard?
0
Accepted
Marin Bratanov
Telerik team
answered on 07 Feb 2014, 03:33 PM
Hi,

There shouldn't be a difference whether the button is in a wizard or not. What is important is where the wizard is. If it is in the ContentTEmplate of the RadWindow you would need to use the $find() method to get the reference, as shown here: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx.

If it is in a content page then there shouldn't be an issue and I would advise removing the AjaxControlToolkit to see if this is causing the problem (e.g., handlers not being fired).

I am attaching here a small sample that works fine for me. Please compare it with your actual setup to find the difference that is causing the problem.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Window
Asked by
Veer
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Veer
Top achievements
Rank 1
Share this question
or