Closing a Radwindow inside another Radwindow

4 posts, 0 answers
  1. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 18 Jul 2013 Link to this post

    Hi guys,

    I had look through your posts and cant seem to find what i am looking for.

    Could someone please post a link to a answer to my question because im sure this would have been answered before.

    Inside of my 1st Radwindow a user will have an option so search for a customer, When the user clicks on a button it opens another RadWindow inside of my current RadWindow. my 2nd Radwindow will pass data to the 1st RadWindow if the save button is clicked.

    The 2nd RadWindow has a "Save" and "Close" button.

    What i need is when the save button or close button is clicked the 2nd Radwindow will close and display the 1st one again

    Thnx in advance.
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2013 Link to this post

    Hello newguy,

    Are you using the RadWindow's NavigateUrl or ContentTemplate?

    With NavigateUrl, the GetRadWindow approach should work.
    With ContentTemplate, you would just use the $find approach to get the specific window you want to close when the button is pressed.

    I hope that helps. If not, if you could post a simple example of what you're trying to do.

    Kevin
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 19 Jul 2013 Link to this post

    I am currently on my main.aspx page

    RadWindow is being opened as follows
    <telerik:RadCodeBlock runat="server" >
        <script>
     
                function ShowEditForm(id, rowIndex) {
                    var grid = $find("<%= grdIncidents.ClientID %>");
     
                    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
                    grid.get_masterTableView().selectItem(rowControl, true);
     
                    window.radopen("EditIncidents.aspx?IncidentID=" + id, "IncidentListDialog");
                    return false;
                }
     
              function ShowInsertForm() {
                    window.radopen("EditIncidents.aspx", "IncidentListDialog");
                    return false;
                }
     
    </script>
    </telerik:RadCodeBlock>

    Here is my RadWindowManager on my Main.aspx page
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="True" VisibleStatusbar="false">
            <Windows>
         <telerik:RadWindow ID="IncidentListDialog" runat="server" Title="Incident" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"
                                               OnClientClose="RefreshParentPage" OnClientBeforeClose="winDetailClosing" InitialBehaviors="Maximize" Behaviors="None" >
                            </telerik:RadWindow>
                             
       </Windows>              
    </telerik:RadWindowManager>


    Now i currently have my RadWindow Open, and what i want to achieve is close the radWindow and return to my Main.aspx page once the save button has been clicked.

    i cannot understand why the close script at the bottom doesnt want to close my radwindow

    Save button Code
    protected void btnSave_Click(object sender, EventArgs e) // Add a new Consumer to the DB
            {
                Consumer cons = new Consumer();
                try
                {
                    cons.Salutation = tbSalutation.Text;
                    cons.FirstName = tbFirstName.Text;
                    cons.LastName = tbLastName.Text;
                    cons.IDNumber = tbIDNumber.Text;
                    cons.email = tbEmail.Text;
                    cons.tel = tbPhone.Text;
                    cons.mobile = tbMobile.Text;
                    cons.fax = tbFax.Text;
                    cons.Address1 = tbAddressLine1.Text;
                    cons.Address2 = tbAddressLine2.Text;
                    cons.Address3 = tbAddressLine3.Text;
                    cons.Address4 = tbAddressLine4.Text;
                    cons.PostCode = tbPostalCode.Text;
                    cons.SendEmail = false;
                    cons.SendSMS = false;
                    cons.LastUpdated = DateTime.Now;
                    cons.UpdatedBy = Convert.ToString(Session["LoggedUserName"]);
     
                    if (chkActive.Checked)
                    {
                        cons.Active = true;
                    }
                    else
                    {
                        cons.Active = false;
                    }
     
                    db.Consumers.Add(cons);
                    db.SaveChanges();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Consumer Successfully Added')", true);
                    clearControls();
                    Page.ClientScript.RegisterStartupScript(GetType(), "key", "<script type='text/javascript'>CloseWindow();</script>", false);
                }
                catch(Exception ex)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + ex.Message + "')", true);
                }
            }

    here is the script that i am using to close the window
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
      <script type="text/javascript">
     
                function CloseWindow() {
                    GetRadWindow().Close();
                }
     
       </script>
    </telerik:RadCodeBlock>

  5. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 19 Jul 2013 Link to this post

    I have found my Error.

    I left out a part of the script.

    The closing script should look like this
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script>
     
                       function GetRadWindow() {
                           var oWindow = null;
                           if (window.radWindow)
                               oWindow = window.RadWindow;
     
     
                           else if (window.frameElement.radWindow)
                               oWindow = window.frameElement.radWindow;
                           return oWindow;
                       }
     
                       function CloseWindow() {
                           GetRadWindow().Close();
                       }
     
    </script>
    </telerik:RadCodeBlock>
Back to Top