Fellow programmer, I am new to ASP.NET and am in need of some advice. I am executing a Stored Procedure in the OnInit function and after it executes, I would like to close the window and display an alert message. Below is the code snippet which executes the stored procedure and closes the window. But I am not able to display the alert message.



protected override void OnInit(EventArgs e)

{

sAction = Request.QueryString["action"];

String sId = Request.QueryString["id"];

int iId = sId == null ? 0 : int.Parse(sId);

this.EditFarmID = iId;

DeleteFrmEntryDS(this.EditFarmID);

ClientScript.RegisterStartupScript(GetType(), "alert", "<script type=\"text/javascript\">window.opener=self; window.close();</script>");



}

}



If I include the Alert towards the end of my JS, then the alert displays, but the window does not close. Its because of the timing.



I am trying to reduce creating extra asp pages and would prefer to do everything in fewer amounts of asp pages needed. That’s why I am doing the processing of my SP in the same page as the form.



Any help would be appreciated.