Re: Displaying messages/errors to users. Opinions?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Saunders (john.saunders)
Date: 03/29/04


Date: Mon, 29 Mar 2004 07:45:30 -0500


"NewsMonkey" <newsmonkey@speakeasy.net> wrote in message
news:MPG.1ace99bf34549d8f989681@news.speakeasy.net...
> Hi All,
>
> I have been working on a few ASP.NET applications recently that access
> database resources frequently. I have been trying to find a consistent
> way of displaying both the success and failure of various operations to
> the user. For example, if a new record is successfully added then I
> would like to display a short message saying "The record has been added
> successfully". Likewise if an error occurs then I would like to display
> the "Message" attribute of the exception that was thrown.
>
> The problem I am having, is coming up with a consistent method of
> displaying these messages. Should I place the message into a Session
> object and then redirect to a new page that reads the message from the
> Session object? Another method I could use would be to place the error
> message into the body of a hidden "<DIV></DIV>" element and then set the
> visibility to "visible". I guess I am just looking for tips and
> techniques that others use to accomplish this sort of task, also, any
> "tutorial/articles" that might cover this subject would be very helpful.
> It would be great if I could "aggregate" the functionality into a
> reusable class or object and just use it within other asp.net
> applications. Thanks in advance for any help!

What I do is to set a couple of Session variables when I want a message to
display - one for the message, one for formatting information. Then, I have
every page check those variables during Page_Load. If they're found to be
set, the text is formatted into a label control on the page and then cleared
from the session variable. This way, if the page uses Response.Redirect, the
next page will see the message.

I also have a variant of this code which displays the message on the same
page.

You don't really want the user to see the Message text of system exceptions,
though. Some of those SQL Server messages can look to a user like the world
is ending! You'll want to interpret your exceptions and display something
the user can understand. At the same time, you should consider logging the
complete exception to the event log, possibly as a Warning message. That
way, if your user complains about "Can't add row - maybe duplicate", you can
check the event log and see the full exception.

-- 
John Saunders
John.Saunders at SurfControl.com


Relevant Pages

  • Re: Displaying messages/errors to users. Opinions?
    ... > I have been working on a few ASP.NET applications recently that access ... Likewise if an error occurs then I would like to display ... What I do is to set a couple of Session variables when I want a message to ... You don't really want the user to see the Message text of system exceptions, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Performance problem related to sysfader, msdtc, davcdata
    ... Documents submenu on the Start Menu sysfader seems to ... but now it just hangs. ... there are no applications running. ... continues to display the menu) ...
    (microsoft.public.windowsxp.perform_maintain)
  • Re: Visual Basic for Applications Help not working right.
    ... another in one of the common files directories. ... common files area into the office/1033 directory the search results display, ... entitled visual basic for applications, ... >> VBA help files. ...
    (microsoft.public.excel)
  • Re: domain-specific language
    ... >> option:display do ... >> application:xterm do ... >> application:xeyes do ... I have some applications that take env ...
    (comp.lang.ruby)
  • ScaryBear Software releases udpated Today Screen plugins and More
    ... Today Screen Plugin Updates ... Updated the icons on the main display. ... Return of the Freeware Applications ...
    (microsoft.public.pocketpc)