Closing RadWindow and AjaxRequest problem

8 posts, 0 answers
  1. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 07 Sep 2011 Link to this post

    I've looked around the forums a bit and can't find an issue that relates exactly to my scenario.

    I've got a Radwindow, with 2 buttons on,

    A cancel button (OnClientClick = 'CancelEdit')
    and a save button (iniates postback, runs some server side code then calls the CloseAndRebind method with ClientScript.RegisterStartupScript. )

    This all works, however, when i click the 'save and close button' it closes the radwindow, refereshes the control on the page below (in this case a listview) but then the radwindow reopens, and i'm not sure why.

    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) {
            oWindow = window.radWindow; //Will work in Moz in all cases, including classic dialog
        }
        else if (window.frameElement.radWindow) {
            oWindow = window.frameElement.radWindow; //IE (and Moz as well)
        }
        return oWindow;
    }
     
    function CloseAndRebind() {
        try {
            GetRadWindow().BrowserWindow.refreshAddresses();
        }
        catch (err) {
        }
        GetRadWindow().Close();
    }
     
    function CancelEdit() {
        GetRadWindow().Close();
    }

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Sep 2011 Link to this post

    Hello Alan,

    Please take a look into the following thread which discussed similar issue.
    Stop RadWindow from always loading on page postback.

    Thanks,
    Princy.
  3. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 07 Sep 2011 Link to this post

    Hi Princy, had already looked at that actually. I did however try adding VisibleOnPageLoad = false , but that made no difference. Because i've never actually set that to true.

    FYI, the window opens once the Ajax Request function has completed.

  4. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 07 Sep 2011 Link to this post

    UPDATE: so after some further reading, i decided to set the VisibleOnPageLoad property to false on my AjaxRequest, assuming that this gets changed to true on radopen.

    The RadWindow actually seems to have reopened prior to the AjaxRequest.

    However, no luck.

    UPDATE2:

    OK it opens before the page load of the page that initially opened the window.

    Just to clarify, i'm opening the window on the OnClientClick event, but i'm closing it by injecting the client side script as i need to run some server side script first.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4625 posts

    Posted 08 Sep 2011 Link to this post

    Hi Alan,

    Please examine this sticky forum thread on opening a RadWindow from the server. It uses the Sys.Application.Load event and does so only once. If you are using the RadAjaxManager's Response Scripts collection it is possible that the script you call to open the RadWindow is called after each AJAX request if you readd it, which would result in the reopening of the RadWIndow. Please try using the logic described in the forum thread instead, as the issue here stems from the way you open the RadWIndow, but you have not posted this code.

    If you are still unable to resolve the issue after applying this approach I advise that you open a support ticket and send us a simple page that reproduces the issue so we can debug it and see what is happening.


    Greetings,
    Marin
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 08 Sep 2011 Link to this post

    Hi Marin, I have read that, and it didn't seem to make any difference.

    I am not opening the RadWindow server side.

    function openRequirement(requirementid) {
        if (requirementid != undefined) {
            radopen("applicant_requirement.aspx?applicant_requirement_id=" + requirementid, "rw_requirement");
        }
    }

    I'm simply using the 'onclick' function to call it
    Private Sub rg_requirements_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rg_requirements.ItemDataBound
        If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = GridItemType.Item Then
            Dim datakey As DataKey = Me.rg_requirements.MasterTableView.DataKeyValues(e.Item.ItemIndex)
            TryCast(e.Item.FindControl("btn_editrequirement"), RadButton).Attributes.Add("onclick", "openRequirement('" & datakey("applicant_requirement_id") & "')")
        End If
    End Sub

    As suggested in the thread, i tried setting the VisibleOnLoad property of the radwindow to false on the AjaxRequest. However, the window is reopening prior to the AjaxRequest.

    Here is my code to close the window (which IS from server side)
    Protected Sub updateapplicant_requirementAndClose()
    server side code commiting data to database
    .....
    ClientScript.RegisterStartupScript(Me.GetType, "closeandrebind_applicant_requirement", "CloseAndRebind();", True)
    End Sub

    Which is called by a RadButton 'Command'

    And the Javascript it's calling:

    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) {
            oWindow = window.radWindow; //Will work in Moz in all cases, including classic dialog
        }
        else if (window.frameElement.radWindow) {
            oWindow = window.frameElement.radWindow; //IE (and Moz as well)
        }
        return oWindow;
    }
     
    function CloseAndRebind() {
        try {
            GetRadWindow().BrowserWindow.refreshRequirements();
        }
        catch (err) {
        }
        GetRadWindow().Close();
    }


    Thanks for you response.

    Alan
  7. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 09 Sep 2011 Link to this post

    OK it appears the Javascript CloseAndRebind function isn't actually being called at all.

    I also tried the method of injecting hte script into a label, but no difference.

    http://www.telerik.com/community/forums/aspnet-ajax/window/basic-window-question.aspx

    I've been reading that which may be relevent but its a bit over my head.

    My scenario is:
    The radwindow opens from my content page.
    The content page contains an ajaxmanager.
    The contents of the radwindow page are wrapped in a radajaxpanel.
  8. Alan T
    Alan T avatar
    125 posts
    Member since:
    Apr 2010

    Posted 09 Sep 2011 Link to this post

    Got it, i needed to add the script to the response scripts collection.

    Whay!.

    http://www.telerik.com/community/forums/aspnet/ajax/how-to-close-the-window-which-use-radajaxpanel-by-javascipt.aspx
Back to Top