This is a migrated thread and some comments may be shown as answers.
Closing RadWindow using RadButton
2 Answers 68 Views
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 2
Peter asked on 13 Jan 2012, 10:25 AM
Hi there,

Im trying to use a RadButton to close a radwindow from with the window itself (via javascript). Is it possible to call a script and to close the window?

function getRadWindow()
            {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
 
            function closeWindow()
            {
                getRadWindow().close();
            }



And here is the button:

<telerik:RadButton ID="CancelButton" runat="server" OnClick="closeWindow();" CssClass="clicker" Text="Cancel" UseSubmitBehavior="False" EnableEmbeddedScripts="false" CausesValidation="False" RegisterWithScriptManager="False">
    </telerik:RadButton>


I have tried everything, the script will only work if I use a pure HTML element. If I use the OnClick event I get the following error when the window opens: Compiler Error Message: CS1026: ) expected 


Thanks for your time

Peter

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 13 Jan 2012, 12:45 PM
Hello,

OnClick is server side event. You can use OnClientClicked event of RadButton and set the name as shown below.
ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="click" OnClientClicked="closeWindow"></telerik:RadButton>

Thanks,
Princy.
0
Peter
Top achievements
Rank 2
answered on 13 Jan 2012, 01:39 PM
Thanks for the help Princy, much appreciated!
Asked by
Peter
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 1
Peter
Top achievements
Rank 2
Share this question
or