close rad window on another radwindow

6 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 03 Oct 2011 Link to this post

    Thanks. The example helps.
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 04 Oct 2011 Link to this post

    Hi J J,

    I am not sure how exactly you are calling this method, but I advise that you examine the following help article on executing a JavaScript function from the server: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-javascript-from-server-side.html.

    I have also attached a simple page that opens a RadWindow from a RadWindow and closes the second one from within via a JS function call from the code-behind. You can compare it with yours and try to locate any major differences.


    Regards,
    Marin
    the Telerik team
    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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 04 Oct 2011 Link to this post

    Hi Marin,

    Thank you very much for the example, it helps.
    One question: How can I make the first radwindow refersh after the second radwindow OnclientClose (use he "X" to close)

    I put hte following on the first radwindow but give me error "OnClientClose2 not defined", this one works on the first radwindow.

    function

     

     

    OnClientClose2(sender, eventArgs) {

     

    top.location.href = top.location.href;

    }

    function OnClientClose2(sender, eventArgs) {
                 top.location.href = top.location.href;     
            }
      
     <telerik:RadWindowManager ID="custFileHistWindowMgr" runat="server" IconUrl="/img/radwindowicon.gif"
                Style="z-index: 7001">
                <Windows>
                    <telerik:RadWindow ID="wndNewFileReq" runat="server" Modal="true" KeepInScreenBounds="true"
                        Height="450px" Width="700px" Animation="Fade" AutoSizeBehaviors="Default" ShowContentDuringLoad="true"
                     OnClientClose="OnClientClose2"    VisibleStatusbar="false" Behaviors="Close,Move" NavigateUrl="/DataFiles/NewFileRequest.aspx" />
                </Windows>
    </telerik:RadWindowManager>
    Thanks!
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 05 Oct 2011 Link to this post

    Hello J J,

    The top.location.reload() (which is essentially the same as copying the href) would reload the entire page. What you need to do is:

    1) get a reference to the desired RadWindow in its OnCilentClose event (which should be declared in the parent page of the RadWindow you just closed).
    This can be done either via the $find() method, or via the RadWindowManager's getWindowByName method if your RadWIndows are in the the Windows collection of a RadWindowManager. With this I am assuming that your project structure is like my demo - a parent page with both RadWindows declared in it, so you can access them both from this page. This is where the OnClientClose handlers should be declared

    2) Then you can call its reload() method so that the page is refreshed (please note that the page needs to be from the same domain for this to work, this is a generic JavaScript limitation). More information on the matter is available in the RadWindow's Client-side API reference.

    Greetings,
    Marin
    the Telerik team
    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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 07 Oct 2011 Link to this post

    On your default.aspx example, I added the following:
    function OnClientClose(sender, args) {
             alert('here');
             GetRadWindow().close();
             GetRadWindow().reload();
         }
    But alert 'here" doesn't even triggered. is there anything I understand wrong? Thanks.
  7. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 10 Oct 2011 Link to this post

    Hi J J,

    In which page have you placed this function? It should be placed in Default.aspx as this is where the RadWindows "live". What I see is that you call the GetRadWindow() function as well, so I am inclined to think you have placed it in one of the pages, loaded within the RadWindows. If so - then there is no way for the parent page to call this handler, as it is in another document.

    A handler should be placed in the page that hosts the control and you also have a reference to the said control as the first parameter passed to the handler, so you should use it instead of the GetRadWindow() function.

    Please also make sure that you have attached the handler to the event - as seen in the markup of the second RadWindow in my example. You can also add event handlers via JavaScript as shown here.

    Please examine the attachment to this post - the previous project with the added close handler, as it seems to be working as expected on my end: http://screencast.com/t/EVhHXVlqID. Please also note my comments in the code.


    Best wishes,
    Marin
    the Telerik team
    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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017