Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / November 2007

Tip: Looking for answers? Try searching our database.

ASP.NET message box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Goran Djuranovic - 05 Nov 2007 19:06 GMT
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
Mark Rae [MVP] - 05 Nov 2007 19:54 GMT
> 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'"...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Goran Djuranovic - 05 Nov 2007 20:26 GMT
Mark,
OK, this automatically generates the script tags, but doesn't seem to help
the main problem. Any other suggestions?

Thanks
Goran

>> ClientScript.RegisterClientScriptBlock(Me.Page.GetType(), "ErrorMessage",
>> "<script language='javascript'> alert('Error:" & ErrorMessageStr &
[quoted text clipped - 6 lines]
> automatically, so you avoid using deprecated syntax like
> "language='javascript'"...
Mark Rae [MVP] - 05 Nov 2007 21:08 GMT
> OK, this automatically generates the script tags, but doesn't seem to help
> the main problem. Any other suggestions?

Apologies - I didn't read your post closely enough...

This should solve your problem:
http://www.velocityreviews.com/forums/t368755-making-sure-page-loads.html

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Goran Djuranovic - 05 Nov 2007 21:21 GMT
Mark,
Exactly what I needed.

Thanks a bunch.
Goran

>> OK, this automatically generates the script tags, but doesn't seem to
>> help the main problem. Any other suggestions?
[quoted text clipped - 3 lines]
> This should solve your problem:
> http://www.velocityreviews.com/forums/t368755-making-sure-page-loads.html

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.