Call a javascript function from call behind

Hi,

I have a form opened in a radWindow. The RadWindow has to be closed using a javascript function.
However I want to save the work done before closing the window, using the btnClose_Click event in code behind.
I am new to JavaScript and followed instruction/example on the web, and it does not work.
Thanks for helping me and letting me know what is not working.

This is my code:

aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="QuestionBuilder.aspx.cs" Inherits="SAPPHIRE.Form.Group.QuestionBuilder" %>

<%@ Register Src="~/Control/Assessment/Builder/sks_QuestionUpd.ascx" TagName="Question" TagPrefix="sks" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <form id="form1" runat="server">

        <tlk:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts></Scripts>
        </tlk:RadScriptManager>

        <sks:Question ID="ctlQuestion" runat="Server"  visible="False" OnClick="ctlMenu_Click"/>

        <tlk:RadButton ID="btnClose" runat="server" Text="Close"  OnCommand="btnClose_Click"/>
        <cc1:ConfirmButtonExtender ID="cnfmCloseBtnExt" runat="server" TargetControlID="btnClose"  
        ConfirmText="Do you want to save prior to close the form?"/>

	<script type="text/javascript">
		function Close() {
                    GetRadWindow().close();
                }
        </script>
    </form>
</body>
</html>

Open in new window


aspx.cs file (btnClose_Event):
        
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;

protected void btnClose_Click(object sender, CommandEventArgs e)
        {
            this.ctlQuestion.UpdateData();

            ClientScript.RegisterStartupScript(this.GetType(), "", "close()", true);
        }

Open in new window

AnneSKSAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle AbrahamsSenior .Net DeveloperCommented:
use ScriptManager.RegisterStartupScript instead as you're using ajax.

Here's an example:
http://www.telerik.com/forums/closing-radwindow-after-server-side-code-has-executed-within-radwindow

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AnneSKSAuthor Commented:
Thanks a lot, it's working!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.