This is my javascript function ,
function returnToParent() {
var oArg = new Object();
var oWnd = GetRadWindow();
oArg.ReturnValue = "Submit";
oWnd.close(oArg);
}
And this is how I call this function on client side
<button title="Submit" runat="server" id="close" onclick="returnToParent(); return false;">
OK</button>
I want to fire this function in server side button click event .
What I've done is add new button
<asp:Button runat="server" ID="rtxtSubmitChange" OnClick="rtxtSubmitChange_Click" Text="Submit" />
and in ButtonClick Event ,
protected void rtxtSubmitChange_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(GetType(),
"MyKey",
"returnToParent();",
false);
}
But It doesn't work . What I am wrong in my code ?
OnClickis to be handled on the server side (C#), andOnClientClickon the client (Javascript). So, besides fixing your markup, you should call the Javascript function from the server side just if there's something you need to do before doing so. Otherwise, just use theOnClientClick.OnClick="rtxtSubmitChange_Click".Page.ClientScriptis deprecated. UseClientScriptManagerinstead. But if you're playing withUpdatePanels, useScriptManagerinstead. Also, when you stick a breakpoint on the click handler, does it get hit?