Sunday, March 1, 2009

Image & Sound in Validator Controls

I am going to give code snippets for a very interesting trick.ie,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">
</asp:requiredfieldvalidator>


for displaying image instead of text we are giving an img tag with src set to a image in our application.so 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">
</asp:requiredfieldvalidator>


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

0 comments:

Post a Comment