Search content within the blog

Wednesday, May 20, 2009

Using Sounds and Images For Error Notification

So far, we have been displaying simple textual messages for the error notifications that come from the
validation server controls. In most instances, you are going to do just that — display some simple
textual messages to inform end users that they input something into the form that doesn’t pass your
validation rules.
An interesting tip regarding the validation controls is that you are not limited to just text — you can also
use images and sounds for error notifications.
To do this, you use the Text property of any of the validation controls. To use an image for the error, you
can simply place some appropriate HTML as the value of this property.

Using images for error notifications
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
Runat="server" Text=’<img src="error.gif">’

Using sound for error notifications
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
Runat="server" Text=’<bgsound src="C:\Windows\Media\tada.wav">’
ControlToValidate="TextBox1" EnableClientScript="False">

No comments:

Post a Comment