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

Stop RadWindow From closing on button Click

5 Answers 270 Views
Window
This is a migrated thread and some comments may be shown as answers.
newguy
Top achievements
Rank 1
newguy asked on 04 Jul 2013, 07:28 AM
Hi,

I have a main.aspx page, when a user clicks on a link button in a gridView a RadWindow is displayed with a EditIncident.aspx page inside of it.
I have 3 buttons on the Incident.aspx page (Save, Clear and Cancel) This all works great but once the RadWindow is open no matter which button i click on the RadWindow Will close. How can i prevent this. I have looked through some of the examples and none have seemed to work for me.


Script i am using to open the window
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;
}

RadWindow
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="True" RestrictionZoneID="RadPane1" ReloadOnShow="true" >
<Windows>
 
<telerik:RadWindow ID="IncidentListDialog" runat="server" Title="Incident" Modal="false" ReloadOnShow="true" ShowContentDuringLoad="false" Width="900px" Height="760px" Top="80px" Left="100px" >
</telerik:RadWindow>
 
 </Windows>
</telerik:RadWindowManager>


5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 04 Jul 2013, 10:42 AM
Hi newguy,

If you are making a postback when you click any of those buttons, such behavior is expected - the page is reloaded and so any dynamically created HTML element will be destroyed and hence the RadWindow is destroyed and cannot be seen. To avoid that you could Ajaxify the button. Another option is to set the VisibleOnPageLoad property of the RadWindow to true inside the particular button click server side code where you need to display the window after PostBack.

Thanks,
Princy.
0
newguy
Top achievements
Rank 1
answered on 04 Jul 2013, 01:09 PM
Thank you. Got it sorted
0
newguy
Top achievements
Rank 1
answered on 04 Jul 2013, 01:41 PM
my mistake its not sorted, i forget i was preventing the window from closing with the OnClientBeforeClose event with the following script

function winDetailClosing(sender, e) {
                e.set_cancel(true);
            }

if i set the AutoPostBack = False, nothing happens including my save button does nothing, my clear button does nothing and my form window still closes is i remove the script that prevents it from closing
0
newguy
Top achievements
Rank 1
answered on 05 Jul 2013, 07:40 AM
To avoid that you could Ajaxify the button. Another option is to set the VisibleOnPageLoad property of the RadWindow to true inside the particular button click server side code where you need to display the window after PostBack.

How would i go about doing this?
0
newguy
Top achievements
Rank 1
answered on 05 Jul 2013, 09:25 AM
I have found a solution to this problem.

While reading other posts, after my Edit.aspx has been opened in the RadWindow, and Save button has been clicked, the parent page should also refresh. by doing this i have also resolved my PostBack Issues and prevented my window from closing when i was not supposed to. now my RadWindow will only close once the Close button he been clicked.

here is my main.aspx RadWindow code.
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"
 EnableShadow="True" RestrictionZoneID="RadPane1" ReloadOnShow="True">
<Windows>
 
<telerik:RadWindow ID="IncidentListDialog" runat="server" Title="Incident"
Modal="false" ReloadOnShow="true" OnClientClose="RefreshParentPage"
ShowContentDuringLoad="false" Width="900px" Height="760px" Top="80px"
Left="100px"  OnClientBeforeClose="winDetailClosing"
Behavior="Resize, Minimize, Maximize"
Behaviors="Resize, Minimize, Maximize">
</telerik:RadWindow>
 
 <telerik:RadWindow ID="IncidentActionsDialog" runat="server" Title="Actions"
 Modal="false" ReloadOnShow="true" ShowContentDuringLoad="false" Width="900px"
Height="760px" Top="80px" Left="100px" Overlay="True"
 Behavior="Resize, Minimize,Maximize, Close"
 Behaviors="Resize, Minimize, Maximize, Close" >         
</telerik:RadWindow>
 </Windows>
 
</telerik:RadWindowManager>

Script on the main.aspx
// Refresh the parent page
function RefreshParentPage()
            {
                document.location.reload();
            }
 
 // Prevent the RadWindow from closing
            function winDetailClosing(sender, e) { 
                e.set_cancel(true); 
            }

Buttons in my Edit.aspx
<telerik:RadButton ID="btnSave" runat="server" AutoPostBack="true" CausesValidation="true" Onclick="btnSave_Click" Text="Save" Width="100px">                       
</telerik:RadButton>
 
<telerik:RadButton ID="btnClear" runat="server" AutoPostBack="true" CausesValidation="false" OnClick="btnClear_Click" Text="Clear" Width="100px">
</telerik:RadButton>
 
<telerik:RadButton ID="btnClose" runat="server" AutoPostBack="false" CausesValidation="false" Text="Close" Width="100px" OnClientClicked="closeWin" >
</telerik:RadButton>

script on the Edit.aspx
function closeWin()
            {
                var oWnd = GetRadWindow();
                oWnd.close();
                top.location.href = top.location.href;
            }

This probably wasnt the correct way of doing what was initially intended, but this works for me
Tags
Window
Asked by
newguy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
newguy
Top achievements
Rank 1
Share this question
or