ASP.NET message box

  • Thread starter Thread starter Goran Djuranovic
  • Start date Start date
G

Goran Djuranovic

Hi all,
I have a web form with an error message box that pops up when there is a SQL
error on the back end, after the web form is submitted. Now, the problem is
that the error message pops up before the UI is re-rendered to the page,
causing the page to be blank (white background) with the error message box
being the only thing the user sees.

I know this is happening because when the form is posted back, it needs to
reload. So my question is, is it possible to show the error message after
the GUI (form's controls) is shown. It should behave exactly like a
ValidationSummary message box (although validation is performed before the
postback), with a postback.

The code used to generate an error message box is below:
ClientScript.RegisterClientScriptBlock(Me.Page.GetType(), "ErrorMessage",
"<script language='javascript'> alert('Error:" & ErrorMessageStr &
"');</script>")

Any suggestions welcome?

Thanks
Goran
 
ClientScript.RegisterClientScriptBlock(Me.Page.GetType(), "ErrorMessage",
"<script language='javascript'> alert('Error:" & ErrorMessageStr &
"');</script>")

ClientScript.RegisterStartupScript(GetType(), "ErrorMessage",
"alert('Error:" & ErrorMessageStr & "');", True)

Using the boolean overload makes ASP.NET insert the <script> tags
automatically, so you avoid using deprecated syntax like
"language='javascript'"...
 
Mark,
OK, this automatically generates the script tags, but doesn't seem to help
the main problem. Any other suggestions?

Thanks
Goran
 
Back
Top