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

Stop postback when radWindow is closed

6 Answers 493 Views
Window
This is a migrated thread and some comments may be shown as answers.
Steven Black
Top achievements
Rank 1
Steven Black asked on 23 May 2010, 07:54 PM

Hello,

I noticed that when I click the Cancel button or the 'X' on a radConfirm dialog box, the radConfirm window closes without doing a postback of the original page.  I would like to duplicate this with my own radWindow.  If the user is canceling, there's no need for the postback.

My Cancel button calls the below CloseOnReload function (the same one I've seen throughout this site for closing a radWindow):

 
 
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 az well)  
 
return oWindow;  
 
}  
 
function CloseOnReload() {  
 
GetRadWindow().Close();  
 
}  
 

Is there any way to stop the postback when the user clicks the Cancel button or the 'X'?

Thanks.

Steve

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 May 2010, 02:03 PM

Hello Steven,

As far as I know the page will not reload when closing the window unless you added code for refresh. Could you check whether you added an code in OnClientClose() of radwindow which might cause the issue.

Could you provide some more information about the code that you tried if this does not help?

Shinu.

0
Steven Black
Top achievements
Rank 1
answered on 25 May 2010, 02:29 PM

Hello Shinu,

The entire HTML for my page is as follows:

<head runat="server">  
    <title><asp:Label ID="lblConfirmTitle" runat="server" Text="Confirm Deletion"></asp:Label></title>  
    <link href="~/Eagle.css" rel="stylesheet" type="text/css" /> 
      
     <script type="text/javascript">  
        //This code is used to provide a reference to the RadWindow "wrapper"  
        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 az well)  
            return oWindow;  
        }  
 
        function CloseOnReload() {  
            GetRadWindow().Close();  
        }  
    </script> 
</head> 
<body> 
    <form id="form1" runat="server">  
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"></telerik:RadScriptManager> 
          
        <div> 
            <table border="0" cellpadding="0" cellspacing="0" width="260px">  
                <tr style="height:50px">  
                    <td valign="middle" align="left" style="width:12px"></td> 
                    <td valign="middle" align="left" style="width:40px">  
                        <asp:Image ID="imgImage" runat="server" ImageUrl="~/images/radConfirmImage.gif" /> 
                    </td> 
                    <td valign="top" align="left" style="width:185px">  
                        <asp:Label ID="lblConfirmText" runat="server" CssClass="radConfirmTextStyle" Text="Are you sure you wish to delete this category?"></asp:Label> 
                    </td> 
                </tr> 
                <tr> 
                    <td colspan="2" style="width:52px"></td> 
                    <td align="left">  
                        <asp:Button ID="btnOK" runat="server" Width="70px" CssClass="radConfirmButtonStyle" Text="Ok" />&nbsp;  
                        <asp:Button ID="btnCancel" runat="server" Width="70px" CssClass="radConfirmButtonStyle" Text="Cancel" OnClientClick="CloseOnReload(); return false;" /> 
                    </td> 
                </tr> 
                <tr style="height:30px">  
                    <td colspan="3">  
                    </td> 
                </tr> 
            </table> 
        </div> 
        <asp:TextBox ID="txtID" runat="server" Visible="false"></asp:TextBox> 
        <asp:TextBox ID="txtObject" runat="server" Visible="false"></asp:TextBox> 
    </form> 
</body> 
 

As you can see, I call the CloseOnReload() function when the btnCancel button is clicked.  The radWindow closes, but the parent page reloads and "jumps".  I tried this with a regular HTML button as well with no change in behavior.

Incidentally, I don't really care if the parent page refreshes.  I just want to get rid of the "jumping" so that it APPEARS as though the parent page is not refreshing.

The entire parent page is contained within a radAjaxPanel. 

I don't know if it's relevant or not, but there is no code-behind click event behind the btnCancel button above.

Thanks.

Steve

 

0
Steven Black
Top achievements
Rank 1
answered on 26 May 2010, 07:46 PM

Just an fyi - When I view this thread from my subscriptions page, it says there are 4 posts and 32 visits, with the last post being from a Telerik Admin about 11 hours ago (not including the post I am creating right now of course).  However, when I view the details of the thread I only see 3 posts - the last one being from me.

So, I am still waiting on a response.

Thanks.

Steve
0
GT
Top achievements
Rank 1
answered on 27 May 2010, 03:55 PM
Hi,

You posted the code of the content page, which as far as I see is OK - the button simply closes the RadWindow. We don't know however what is happening in the parent page - I believe that is why Shinu asked if you execute any code in the OnClientClose function. Could you paste the code of the parent page as well?
0
Steven Black
Top achievements
Rank 1
answered on 27 May 2010, 04:06 PM

 

Thanks Hulky.

 

Just asking me for the other info jogged my memory and answered my question.

 

I am indeed calling a function that reloads when the radWindow closes.

 

Steve

0
Ahmed
Top achievements
Rank 1
answered on 28 Nov 2014, 09:49 AM
Hi Steven Black,
                             I'm facing the same issue just like you. can u paste the code to avoid reloading of page after radwindow is closed.
Tags
Window
Asked by
Steven Black
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Steven Black
Top achievements
Rank 1
GT
Top achievements
Rank 1
Ahmed
Top achievements
Rank 1
Share this question
or