Page disappears when alert shows?

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
 
A

Alvin Bruney [MVP]

Replace registerclient... with
Page.Controls.Add(new literalcontrol(
everything after that should stay the same.
 
B

Bruno Sirianni

The RegisterStartupScript method instead RegisterClientScriptBlock I think
can help you!

Brun
 
R

Robert Zurer

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
 
A

Alvin Bruney [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top