I have a message that pops up when the user clicks the save button but it will not display. My other code displays fine but the one for the save button does not.
Here is the code that works:
if (Page.IsValid)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile. Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
}
Here is the code that does not work:
if (Page.IsValid)
{
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con2.Open();
SqlCommand level = new SqlCommand("select accessLevel, User_ID from Table99 where User_ID = @INST_ID AND accessLevel = @accessLevel", con2);
level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
level.Parameters.Add(new SqlParameter("accessLevel", TextBoxaccessLevel.Text));
SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(reader);
foreach (DataRow dr1 in dt1.Rows)
{
int returnedLevel = Convert.ToInt32(dr1[0].ToString());
int accessLevel = Convert.ToInt32(dr1[1].ToString());
Session["accessLevel"] = accessLevel;
if (returnedLevel == 1)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 2)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 3)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 11)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 21)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 31)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
}
else if (returnedLevel == 7)
{
ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='CEOPage.aspx';", true);
}
}
con2.Close();
What did I do wrong?