Stop RadWindow From closing on button Click

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

    Posted 04 Jul 2013 Link to this post

    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>


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 04 Jul 2013 Link to this post

    Thank you. Got it sorted
  5. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 04 Jul 2013 Link to this post

    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
  6. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 05 Jul 2013 Link to this post

    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?
  7. newguy
    newguy avatar
    26 posts
    Member since:
    May 2013

    Posted 05 Jul 2013 Link to this post

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