I am looking for a code snippet to execute a JavaScript function called recordInserted() that displays an alert, within the add_Click method in my code-behind file. Here is the relevant section of my code:
protected void add_Click(object sender, EventArgs e)
{
String gradename = txt_gradename.Text;
int allocatedclasses = Int32.Parse(txt_allocatedclasses.Text);
String headid = txt_head_id.Text;
int numberofstudents = Int32.Parse(txt_numberofstudents.Text);
db = new DBConnection();
db.getConnection();
db.executeUpdateQuery("INSERT INTO Grade (GradeName,AllocatedClasses,GradeHeadID,NumberOfStudents) VALUES ('"+gradename+"','"+allocatedclasses+"','"+headid+"','"+numberofstudents+"')");
//I Need to call it from here before redirecting
Response.Redirect("AdminReferenceGradeAdd.aspx");
}
Your assistance with this would be greatly appreciated.
I have attempted the following without success:
Page.ClientScript.RegisterStartupScript(this.GetType(),"Call my function","recordInserted()",true);