Close RadWindow from Button inside Asp.Net Wizard Control

4 posts, 2 answers
  1. RP2414
    RP2414 avatar
    14 posts
    Member since:
    Jul 2011

    Posted 03 Feb 2014 Link to this post

    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>
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 05 Feb 2014 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RP2414
    RP2414 avatar
    14 posts
    Member since:
    Jul 2011

    Posted 06 Feb 2014 Link to this post

    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?
  5. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 07 Feb 2014 Link to this post

    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.
Back to Top