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

Radwindow returns argument when manually closed

2 Answers 188 Views
Window
This is a migrated thread and some comments may be shown as answers.
Brenden
Top achievements
Rank 1
Brenden asked on 11 Feb 2009, 09:47 PM
I have created a sample page which is demonstrating the problem I am encountering.  When you click the link on the page, it opens a radwindow.  Within that radwindow, if you click on the link titled 'close me with argument' the window is closed with an argument, the javascript validates the argument then the page does a postback and the server time is displayed on the page.  (I have a radgrid on the page, as this emulates what I am actually doing on my live page).  Then after the page has posted back, if you open the radwindow again and simply close the window (click the X on the toolbar) the argument is still passed to the javascript function.  How can i prevent this from happening?  Below is my sample project using version Q3 2008.  Thanks for your help!

Test.aspx (load me)

<%@ Page language="VB" CodeFile="test.aspx.vb" AutoEventWireup="false" Inherits="_test" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
<html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"
<head> 
    <title></title> 
    
    <script type="text/javascript"
    function ShowDeleteForm() 
    { 
        window.radopen("test2.aspx""AdWindow"); 
    } 
     
 
    function OnClientClose(oWnd) 
    { 
        //get the transferred arguments 
        var arg = oWnd.argument; 
        if(arg) 
        { 
            if (arg.Value == 'true') { 
                __doPostBack("<%=RadGrid1.UniqueID%>"'DeleteAd;12345');   
            } 
        } 
    }     
 
 
    </script>   
     
</head> 
<body> 
    <form runat="server" id="mainForm" method="post"
        <asp:ScriptManager id="ScriptManager1" runat="server" /> 
 
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista"
            <Windows> 
                <telerik:RadWindow Skin="Vista" ID="AdWindow" runat="server" Height="200px" Width="400px" 
                    Left="150px" ReloadOnShow="true" Modal="true" VisibleStatusbar="false" OnClientClose="OnClientClose" ShowContentDuringLoad="false" /> 
            </Windows> 
        </telerik:RadWindowManager> 
 
 
            <telerik:RadAjaxPanel  
                ID="RadAjaxPanel1"  
                runat="server" 
                LoadingPanelID="LoadingPanel1"
                    <asp:UpdatePanel ID="UpdatePanel3" runat="server"
                        <ContentTemplate> 
                            <telerik:RadGrid ID="RadGrid1" runat="server"
                            </telerik:RadGrid>    
 
                            <asp:Literal ID="ltlContent" runat="server"></asp:Literal> 
                            <br /><br /> 
                            <a href="javascript:ShowDeleteForm();">click me</a> 
                             
                        </ContentTemplate>                                                                 
                    </asp:UpdatePanel>                                                                 
            </telerik:RadAjaxPanel> 
            <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Transparency="35" BackColor="#E0E0E0"
                <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'  
                    style="margin-top: 50px; margin-left: 0px; position:relative;" /> 
            </telerik:RadAjaxLoadingPanel>         
 
 
    </form> 
</body> 
</html> 
 

Test.aspx.vb

Partial Class _test 
    Inherits System.Web.UI.Page 
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
        If IsPostBack Then 
            Dim passedArgument As String = Request.Params.[Get]("__EVENTARGUMENT"
            If Not (passedArgument Is NothingAnd passedArgument <> "" Then 
                If passedArgument.IndexOf("DeleteAd") <> -1 Then 
                    Dim strArray As String() 
                    strArray = passedArgument.Split(";"
                    postVal(strArray(1)) 
                End If 
            End If 
        End If 
    End Sub 
 
    Private Sub postVal(ByVal strVal As String
        ltlContent.Text = Date.Now & " - " & strVal 
        RadGrid1.Rebind() 
    End Sub 
End Class 

Test2.aspx

<%@ Page language="VB" AutoEventWireup="false" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
<html xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"
<head> 
    <title></title> 
    
    <script type="text/javascript"
        function GetRadWindow() 
        { 
            var oWindow = null; 
            if (window.radWindow) oWindow = window.radWindow; 
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
            return oWindow; 
        } 
     
 
        function returnToParent(val) 
        { 
            var oArg = new Object(); 
            oArg.Value = val; 
 
            var oWnd = GetRadWindow(); 
            
            oWnd.argument = oArg;   
            oWnd.close(); 
        } 
 
 
    </script>   
     
</head> 
<body> 
    <form runat="server" id="mainForm" method="post"
 
        <a href="javascript:returnToParent('true');">close me with argument</a> 
 
    </form> 
</body> 
</html> 


2 Answers, 1 is accepted

Sort by
0
Brenden
Top achievements
Rank 1
answered on 12 Feb 2009, 03:37 PM
Can anyone help me on this?  Thanks
0
Georgi Tunev
Telerik team
answered on 13 Feb 2009, 09:24 AM
Hi Brenden,

In your logic, you add a new argument to the RadWindow object. In OnClientClose however, after checking for such argument and executing your logic in the check, you don't remove the argument.
What happens is:
  1. RadWindow is opened and an argument has been added to it before closing
  2. OnClientClose fires and checks for argument. Since there is one, your code gets executed.
  3. You open RadWindow again and close it after that by using the X button.
  4. OnClientClose is fired again, however the argument still exist from the previous opening - that is why your code gets executed again.

If you clear the argument after the code's execution, you will not get this problem:
function OnClientClose(oWnd)  
{  
    //get the transferred arguments  
    var arg = oWnd.argument;  
    if(arg)  
    {  
        if (arg.Value == 'true') {  
            __doPostBack("<%=RadGrid1.UniqueID%>"'DeleteAd;12345');    
        }  
    } 
    //clear the argument 
    oWnd.argument = null;  
}  

I hope this helps.

Greetings,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Window
Asked by
Brenden
Top achievements
Rank 1
Answers by
Brenden
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or