Page disappears when alert shows?

  • Thread starter Thread starter Robert Zurer
  • Start date Start date
R

Robert Zurer

When I click a Button server control I want two things to happen.

The server returns a string array of error messages.
A Javascript alert appears showing the errors.

I can do this using the following method

public void ShowErrorWindow(string[] errors)
{
string alertString = null;
foreach(string str in errors)
alertString += str + "\\n";
string jscript = "<script language='JavaScript'>alert('" +
alertString + "');</script>";
RegisterClientScriptBlock("key", jscript);
}

The problem is that the page behind the alert dialog disappears and the
reappears when the dialog is closed. This is not the case when the alert
is generated client side.

Can anyone help on this.


Thanks


Robert Zurer
 
Replace registerclient... with
Page.Controls.Add(new literalcontrol(
everything after that should stay the same.
 
The RegisterStartupScript method instead RegisterClientScriptBlock I think
can help you!

Brun
 
Page.Controls.Add(new literalcontrol(

The RegisterStartupScript method instead RegisterClientScriptBlock I think
can help you!


Thank you both so much. Both work well.

I would appreciate your recommendations for a book which would cover
these kind of issues in depth. I'm not new to programming or C# but, as
you can see, have not done much Web front-end coding.


Robert Zurer
 
have a look at my website http://tinyurl.com/27cok
i have a book review section. it's difficult to recommend a book because
different books cater to different levels. if you need an all encompassing
book a few levels up from starter, try walthers. If you are at the expert
level and need to know why stuff happens, esposito is where it is.
 
Back
Top