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

Refresh Parent window on RadWindow Close

11 Answers 869 Views
Window
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 22 Apr 2011, 09:17 PM
Ok, so Ive read a bunch of posts on how to do this, but cant seem to get them to work. Can anyone give me some help on how to get this to work.
Thanks
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SchoolsAttended.ascx.cs"
    Inherits="Controls_SchoolsAttended" %>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function RowDblClick(sender, eventArgs) {
            sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
        }
        function openRadWin() {
            radopen("AddSchool.aspx", "RadWindow1");
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="rgSchoolsAttended" runat="server" ShowStatusBar="True" AllowSorting="True"
    PageSize="7" GridLines="None" AllowPaging="True" CellSpacing="0" DataSourceID="ldsSchoolsAttended"
    AutoGenerateColumns="False" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
    AllowAutomaticUpdates="True">
    <MasterTableView DataSourceID="ldsSchoolsAttended" DataKeyNames="SchoolAttendedID"
        TableLayout="Fixed" EditMode="InPlace" CommandItemDisplay="Bottom">
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <CommandItemTemplate>
            <div style="padding: 5px 5px;">
                <button id="rbAddSchool" runat="server" onclick="openRadWin(); return false;">
                    Add School
                </button>
                   
                <asp:LinkButton ID="LinkButton2" runat="server" ToolTip="Add School Atteneded" CommandName="InitInsert"
                    Visible='<%# !rgSchoolsAttended.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../App_Themes/Huntsman/Grid/AddRecord.gif" /></asp:LinkButton>  
                <asp:LinkButton ID="LinkButton4" runat="server" ToolTip="Refresh" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../App_Themes/Huntsman/Grid/Refresh.gif" /></asp:LinkButton>
            </div>
        </CommandItemTemplate>
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridEditCommandColumn HeaderStyle-Width="30" ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <ItemStyle CssClass="MyImageButton" />
            </telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="SchoolAttendedID" DataType="System.Int32" FilterControlAltText="Filter SchoolAttendedID column"
                HeaderText="SchoolAttendedID" SortExpression="SchoolAttendedID" UniqueName="SchoolAttendedID"
                Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="SchoolID" DataType="System.String" FilterControlAltText="Filter SchoolID column"
                HeaderText="SchoolID" SortExpression="SchoolID" UniqueName="SchoolID" Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderStyle-Width="160" HeaderText="SchoolName" ItemStyle-Width="240px">
                <ItemTemplate>
                    <%#DataBinder.Eval(Container.DataItem, "SchoolAttendedName")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox runat="server" ID="rcbSchools" DataTextField="SchoolName" DataValueField="SchoolID"
                        DataSourceID="ldsSchools" SelectedValue='<%#Bind("SchoolID") %>'>
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridDateTimeColumn HeaderStyle-Width="160" DataField="BeginDate" DataType="System.DateTime"
                FilterControlAltText="Filter BeginDate column" HeaderText="Start" SortExpression="BeginDate"
                UniqueName="BeginDate" DataFormatString="{0:d}" Visible="false">
            </telerik:GridDateTimeColumn>
            <telerik:GridDateTimeColumn HeaderStyle-Width="160" DataField="EndDate" DataType="System.DateTime"
                FilterControlAltText="Filter EndDate column" HeaderText="End" SortExpression="EndDate"
                UniqueName="EndDate" DataFormatString="{0:d}">
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn HeaderStyle-Width="60" DataField="ReceivedDegree" FilterControlAltText="Filter ReceivedDegree column"
                HeaderText="Degree" SortExpression="ReceivedDegree" UniqueName="ReceivedDegree">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn HeaderStyle-Width="60" DataField="GPA" DataType="System.Decimal"
                FilterControlAltText="Filter GPA column" HeaderText="GPA" SortExpression="GPA"
                UniqueName="GPA">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Transcript" FilterControlAltText="Filter Transcript column"
                HeaderText="Transcript" SortExpression="Transcript" UniqueName="Transcript" Visible="false">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn HeaderStyle-Width="30" ConfirmText="Are you sure you want to delete this?"
                ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton"
                CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
            </telerik:GridButtonColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings AllowColumnsReorder="True">
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowDblClick="RowDblClick" />
    </ClientSettings>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
</telerik:RadGrid>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
    <Windows>
        <telerik:RadWindow ID="RadWindow1" runat="server" ShowContentDuringLoad="false" Width="400px"
            Height="400px" Top="" Title="Add School" Modal="true" Behaviors="Default" OnClientClose="RefreshParentPage">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>
<asp:LinqDataSource ID="ldsSchoolsAttended" runat="server" ContextTypeName="DAL.HuntsmanLinqDataContext"
    EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName=""
    OnSelecting="ldsSchoolsAttended_Selecting" OrderBy="EndDate" TableName="SchoolAttendeds"
    Where="HNUMBER == @HNUMBER">
    <WhereParameters>
        <asp:QueryStringParameter Name="HNUMBER" QueryStringField="HNUMBER" Type="Int32" />
    </WhereParameters>
    <InsertParameters>
        <asp:QueryStringParameter Name="HNUMBER" QueryStringField="HNUMBER" Type="Int32" />
    </InsertParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="ldsSchools" runat="server" ContextTypeName="DAL.HuntsmanLinqDataContext"
    EntityTypeName="" OrderBy="SchoolName" Select="new (SchoolID, SchoolName)" TableName="Schools">
</asp:LinqDataSource>

11 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 25 Apr 2011, 11:18 AM
Hello Curt,

You can hook the OnClientColose to the RadWindow and refresh the page using document.location.reload().

function RefreshParentPage()//function in parent page
{
document.location.reload();
}
This function should be placed in the parent page - where your RadWindow / RadWindowManager is. This function should also be hooked to the RadWindow with the OnClientClose property.

If you want to put the refreshing code in the content page, you need to replace document with top. This way you will refer to the topmost page which will be the one from which you open the RadWindow.
e.g.
function closeWin() //function in content page
{
    var oWnd = GetRadWindow();
    oWnd.close();
    top.location.href = top.location.href;
}


Thanks,
Shinu.
0
Curt
Top achievements
Rank 1
answered on 26 Apr 2011, 04:07 PM
Worked Great! Not sure why I couldn't get it going before.
Thanks
0
Mahe
Top achievements
Rank 1
answered on 05 Sep 2012, 07:38 PM
Thanks shinu. It helped me in a flash to solve...
0
Satyanarayan
Top achievements
Rank 1
answered on 24 Jun 2013, 11:56 AM
It helps a lot ...

Thanks,
Satya
0
DogBizPro
Top achievements
Rank 1
answered on 13 Sep 2013, 03:55 PM
I cannot get that to work for me. The window closes but the parent page does not refresh. I am opening the window with JavaScript vs the radWindow.(). Does that matter?
0
Marin Bratanov
Telerik team
answered on 18 Sep 2013, 06:44 AM
Hello Stephanie,

It does not matter how the RadWindow is opened, what is important is that it has an OnClientClose handler that will refresh the page somehow (a call to __doPostBack(), window.location.reload() or the RadAjaxManager ajaxRequest() client-side method are some options). If you share the code that is causing problems on your end we could start investigating the case. In the meantime this demo shows the general approach in action. Note also how the AJAX settings are configured and make sure yours are proper as well.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
DogBizPro
Top achievements
Rank 1
answered on 18 Sep 2013, 12:42 PM
Thanks for the reply. I have been looking at your demos and forums for a few days trying to get this working. Just by chance last night I moved the OnClientClose from the RadWindow tag to the RadWindowManager tag and it works, but of course it is called when every window on that page is closed when I really only need it for the one window.

Why does it not work on the RadWindow tag? I changed nothing else in the code...
0
Marin Bratanov
Telerik team
answered on 18 Sep 2013, 12:54 PM
Hello Stephanie,

At this point my best guess is that you get another RadWindow opened, not the one you expect. This can happen if you use radopen() and you have more than one manager on the page, then the first one is used, so a wrong instance may be created. Details on dealing with this situation are available here: http://www.telerik.com/help/aspnet-ajax/radwindow-troubleshooting-wrong-window-opened.html.

If this is not your case I strongly advise that you post here the code that exhibits this problem so I can actually investigate it, instead of attempt to guess where the problem originates.



Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
DogBizPro
Top achievements
Rank 1
answered on 18 Sep 2013, 02:16 PM
I am not having issues with the window opening. I am having issues with the OnClientClose not firing. I only have one RadWindowManager on the page and if I put the OnClientClose in that tag it works fine. When I move the OnClientClose to the RadWindow it does not fire. That is the issue.
0
Marin Bratanov
Telerik team
answered on 19 Sep 2013, 07:30 AM
Hello Stephanie,

If an unexpected instance is opened it is possible that it simply does not have the needed handlers attached, which is why I asked you to check for this.

Another case where an OnClientClose handler has issues is when the AjaxControlTolkit assembly is present in the solution. It outputs modified MS AJAX scripts that break event handlers. Usually setting the DestroyOnClose property of the RadWindow to false alleviates this problem because it requires less handlers. If it does not - I advise that you test with removing the AjaxControlToolkit (delete the assembly, simply removing the reference may not be enough) to see if it helps.

If neither of these options help - I strongly advise that you share the code that leads to the problem so we can actually investigate it, instead of attempt to guess.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
DogBizPro
Top achievements
Rank 1
answered on 20 Sep 2013, 04:31 PM
I tried adding the DestroyOnClose='true' but that didn't help. I cannot at this time disable the ajax toolkit as we have other controls on that page that need it.....putting it in the RadWindowManager works fine.
Tags
Window
Asked by
Curt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Curt
Top achievements
Rank 1
Mahe
Top achievements
Rank 1
Satyanarayan
Top achievements
Rank 1
DogBizPro
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or