Closing RadWindow using RadButton

3 posts, 1 answers
  1. Peter
    Peter avatar
    9 posts
    Member since:
    Dec 2010

    Posted 13 Jan 2012 Link to this post

    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. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jan 2012 Link to this post

    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.
  3. Peter
    Peter avatar
    9 posts
    Member since:
    Dec 2010

    Posted 13 Jan 2012 Link to this post

    Thanks for the help Princy, much appreciated!
Back to Top