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

Can't close RadWindow via RegisterStartupScript during AJAX request

5 Answers 234 Views
Window
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 11 Jun 2010, 02:23 PM
I've been using RadWindows and very successfully applying the Page.ClientScript.RegisterStartupScript solution to close the RadWindow.  However, when I'm using AJAX within the RadWindow that solution does not close the window when applied during an AJAX request.  Can anyone suggest a method for closing a RadWindow in this situation?  (I'm using a Telerik ASP.NET AJAX release from Apr 2010.)

Here are some specifics on the scenario:
The page (AddItem.aspx) that I'm displaying in the RadWindow is very simple and contains a web user control -- we'll call it Search.ascx.  Search.ascx has a textbox for entering a search string, a "Search" button (btnSearch) and a RadGrid (grdResults) for displaying search hits.  A user selection from the RadGrid (handled via ItemCommand event) raises Search.ascx's "SelectionComplete" event.  AddItem.aspx handles this event and closes itself -- passing back an argument via oRadWin.argument -- which works fine without any AJAX settings in the page or in Search.ascx.  However, if I use a RadAjaxManagerProxy in Search.ascx to show an AJAX loading panel over grdResults (because the search and paging operations sometimes take several seconds) the RadWindow will not close automatically.

I have verified that the RegisterStartupScript call in AddItem is being made in this situation, but I'm assuming that the startup script is not running because AJAX causes only parts of the page to be updated.  How can I force the RadWindow to close itself during a partial postback?

Thanks in advance,
Tom

5 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 15 Jun 2010, 10:52 AM
Hello Tom,

In such scenarios I recommend using ScriptManager.RegisterStartupScript static method. More details about this method can be found in this MSDN article.

All the best,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Tom
Top achievements
Rank 1
answered on 16 Jun 2010, 07:32 PM
Thank you Fiko and the Telerik team: this was exactly what we needed!

(And for others scanning this page in a hurry, note that the solution here is to use ScriptManager.RegisterStartupScript instead of Page.ClientScript.RegisterStartupScript.)
 
--Tom
0
Mo
Top achievements
Rank 1
answered on 11 Oct 2010, 03:59 PM
I used below code to open RAD window on RadPanelBar_ItemClick. Code works fine. but when i click other item
2 RAD windows are opening(previous rad window and current clicked rad window). What do I have to do to get only one RAD window at a time. Note: Page is enabled with AJAX. 

ScriptManager.RegisterStartupScript(Page,

GetType(Page), "RadAlertScript", "Sys.Application.add_load(function(){var t=radopen('../ZWorking/SampleReport.aspx?', null);t.setSize(800,500);t.Center();});", True)

 

0
Georgi Tunev
Telerik team
answered on 14 Oct 2010, 05:53 AM
Hi Mo,

You need to remove the code from Sys.Application.Load after executing it.
e.g. the logic is
var f = function()
{
   //your code here

   //remove the code from Load
   Sys.Application.remove_load(f);
}
Sys.Application.add_load(f);


Check this blog post for more details.

Kind regards,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Boot
Top achievements
Rank 1
answered on 15 Jun 2011, 05:19 PM
Ok, this is my final modification to my posting...

The statement below executes when on button click event, now, if the criteria is not met, the radwindow stays open.  However, if the radwindow does not close the radeditor disapears from the view?

 If Product_Option_Value_Upd(iProductOptionValueID, sHTML1, sHTML2) Then
  'CloseWin()
           sm1.RegisterStartupScript(Page, Me.GetType(), "a""closeWin();"True)
        Else
            lblMsg.Text = "Error, Product option not saved"
        End If


Any Ideas?
Tags
Window
Asked by
Tom
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Tom
Top achievements
Rank 1
Mo
Top achievements
Rank 1
Georgi Tunev
Telerik team
Boot
Top achievements
Rank 1
Share this question
or