ASP.NET message box

  • Thread starter Goran Djuranovic
  • 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
 
M

Mark Rae [MVP]

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'"...
 
G

Goran Djuranovic

Mark,
OK, this automatically generates the script tags, but doesn't seem to help
the main problem. Any other suggestions?

Thanks
Goran
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top