try this in ok button event
Session["id"] = CCode;
ScriptManager.RegisterStartupScript(Page, this.GetType(), "CCode", "<script>window.opener.document.forms[0].submit();window.close();</script>", false);
Session["Code"] = Code;
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "A", "<script>window.returnValue = true;window.close();</script>");
read article also
Window.showmodaldialog[
^]
Window.Open[
^]