A
Andy B
I have the following code inside of a Wizard_Finish_Button_Click event:
NewsDB NewsHelper = new NewsDB();
if(NewsHelper.AddNews(DateTime.Now, SubjectTextBox.Text, BodyTextBox.Text))
{
StringBuilder PopUp = new StringBuilder();
PopUp.Append("<script language = 'javascript'>");
PopUp.Append("alert('Your news article was added successfully!');<");
PopUp.Append("/script>");
ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript",
PopUp.ToString());
Server.Transfer("index.aspx");
}
else {
StringBuilder PopUp = new StringBuilder();
PopUp.Append("<script language = 'javascript'>");
PopUp.Append("alert('Warning! Couldn't add your news article for some
reason!');<");
PopUp.Append("/script>");
ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript",
PopUp.ToString());
AddNewsWizard.ActiveStepIndex=0; //if adding failed, reset and start over...
}
When the event runs, everything works/fails like expected except for the
javascript part. For some reason it gets ignored. Any way to fix this? I got
my example from
http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx
The whole idea was to show a popup saying the add worked if it worked and
show one saying it failed if it failed.
NewsDB NewsHelper = new NewsDB();
if(NewsHelper.AddNews(DateTime.Now, SubjectTextBox.Text, BodyTextBox.Text))
{
StringBuilder PopUp = new StringBuilder();
PopUp.Append("<script language = 'javascript'>");
PopUp.Append("alert('Your news article was added successfully!');<");
PopUp.Append("/script>");
ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript",
PopUp.ToString());
Server.Transfer("index.aspx");
}
else {
StringBuilder PopUp = new StringBuilder();
PopUp.Append("<script language = 'javascript'>");
PopUp.Append("alert('Warning! Couldn't add your news article for some
reason!');<");
PopUp.Append("/script>");
ClientScript.RegisterClientScriptBlock(GetType(), "PopupScript",
PopUp.ToString());
AddNewsWizard.ActiveStepIndex=0; //if adding failed, reset and start over...
}
When the event runs, everything works/fails like expected except for the
javascript part. For some reason it gets ignored. Any way to fix this? I got
my example from
http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx
The whole idea was to show a popup saying the add worked if it worked and
show one saying it failed if it failed.