Image & Sound in Validator Controls

I am going to give code snippets for a very interesting,to display image or sound instead of validation message in ASP.NET Validation controls.

Displaying image

<asp:RequiredFieldValidator ID="reqPercentage" runat="server"
ErrorMessage='<img src="image.gif">' ControlToValidate="txtPercentage">

for displaying image instead of text we are giving an img tag with src set to a image in our when validation is failed it'll show image instead of text.

Sound in Validation Control

<asp:RequiredFieldValidator ID="reqPercentage" runat="server"
ErrorMessage='<bgsound src="sound.wav">' ControlToValidate="txtPercentage">

And also disable client side script for textbox.Run the application yo'll see the change.


Author: narenderraobalguri27 Nov 2008 Member Level: Silver   Points : 0

hi when u r paying sound is there any option to set time?

Author: Arun Jacob28 Nov 2008 Member Level: Gold   Points : 1

Sound will play when validation fires.
Also set client script capability of the controls to false.


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: