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

Close a radwindow on button click

7 Answers 536 Views
Window
This is a migrated thread and some comments may be shown as answers.
Debashis Pyne
Top achievements
Rank 1
Debashis Pyne asked on 01 Jul 2010, 10:49 AM
Hi,

I have a RadWIndow, which opens an external ASPX page.
This page has some fields which stores data after clicking the save button.

I want on the click event of the save button, the radwindow should be closed automatically.

Please suggest.

Thanks,
Debashis

7 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 01 Jul 2010, 01:32 PM
Hello Debashis,

I believe that the following forum thread will be of help:
http://www.telerik.com/community/forums/aspnet-ajax/window/322276-window-close.aspx


Sincerely yours,
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
Debashis Pyne
Top achievements
Rank 1
answered on 01 Jul 2010, 02:28 PM

Hi Georgi,

The examples you mentioned seemed a bit confusing to me.
Let me explain a bit on my issue.

I have a Radgrid displaying data records.
I have a buttton as BtnAdd which, when clicked, opens a RadWindow which in turn has a NavigateUrl property set to AddData.aspx.
 
The AddData.aspx has a few textboxes and a "Add records" button named BtnAddRecords.
When the BtnAddRecords is clicked, the data from the textfields are stored in the DB.

All I want is:

  1. After the data is stored in the DB, the RadWindow should be closed.
  2. The Radgrid should be refreshed.

Please help.

Thanks,
Debashis

0
Debashis Pyne
Top achievements
Rank 1
answered on 02 Jul 2010, 10:01 AM
Hi Guys,

Can anyone please suggest me on this?

Thanks
0
Accepted
Shinu
Top achievements
Rank 2
answered on 02 Jul 2010, 11:04 AM
Hello Debashis,

In the AddData.aspx page, execute your code to update db and call client method 'CloseAndRebind' (which calls another function written in parent page).

C#:
 
        protected void AddButton_Click(object sender, EventArgs e) 
        { 
            // Code for updating db 
            ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true); // Call client method in radwindow page 
        } 

Client code in AddData.aspx:
 
        <script type="text/javascript"
            function CloseAndRebind() { 
                GetRadWindow().BrowserWindow.refreshGrid(); // Call the function in parent page 
                GetRadWindow().close(); // Close the window 
            } 
            function GetRadWindow() { 
                var oWindow = null
                if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog 
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) 
 
                return oWindow; 
            } 
        </script> 


Now in the parent page invoke an ajxRequest() to rebind the grid, which will avoid unnecessary page refresh.
Client Code:
 
      <script type="text/javascript"
            function refreshGrid() 
            { 
                 $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");             
            } 
      </script> 

In the code behind, in write code for rebinding the grid:
 
 
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
            if (e.Argument == "Rebind"
            { 
                RadGrid1.MasterTableView.SortExpressions.Clear(); 
                RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
                RadGrid1.Rebind(); 
            }           
        } 

Also set the AjaxManager Settings accordingly, in parent page:
 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
                <AjaxSettings> 
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                    <telerik:AjaxSetting AjaxControlID="RadGrid1"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        </UpdatedControls> 
                    </telerik:AjaxSetting> 
                </AjaxSettings> 
            </telerik:RadAjaxManager> 


I hope referring the demo on Window Editing will be helpful in achieving this (the code is adopted from the demo itself)  :)





-Shinu.
0
Debashis Pyne
Top achievements
Rank 1
answered on 07 Jul 2010, 02:22 PM
thanks
0
Andrey
Top achievements
Rank 1
answered on 21 Oct 2010, 02:21 PM
   Hello, Shinu.
I use master page in my project, so I use RadAjaxManagerProxy which does not contain "AjaxRequest" event. Can you help me, how can I resolve this problem?
0
Andrey
Top achievements
Rank 1
answered on 21 Oct 2010, 03:45 PM
  Sorry, I find solution myself :)

protected void Page_Load(object sender, EventArgs e)
{
   RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
   manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);
}
protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
   //handle the manager AjaxRequest event here
}
Tags
Window
Asked by
Debashis Pyne
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Debashis Pyne
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Andrey
Top achievements
Rank 1
Share this question
or