Close a radwindow on button click

8 posts, 1 answers
  1. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 01 Jul 2010 Link to this post

    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
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 01 Jul 2010 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 01 Jul 2010 Link to this post

    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

  5. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 02 Jul 2010 Link to this post

    Hi Guys,

    Can anyone please suggest me on this?

    Thanks
  6. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jul 2010 Link to this post

    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.
  7. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 07 Jul 2010 Link to this post

    thanks
  8. Andrey
    Andrey avatar
    7 posts
    Member since:
    Oct 2010

    Posted 21 Oct 2010 Link to this post

       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?
  9. Andrey
    Andrey avatar
    7 posts
    Member since:
    Oct 2010

    Posted 21 Oct 2010 Link to this post

      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
    }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017