Demo:
<%@ Page Language="C#" %> <html> <head id="Head1" runat="server"> <script language="javascript" type="text/javascript"> function PlaySound() { if (typeof (Page_ClientValidate) == "function") { Page_ClientValidate(); if (!Page_IsValid) { var thissound = eval("document.error"); thissound.Play(); return false; } return true; } } </script> </head> <body style="padding:0; margin:0"> <form runat="server" id="form1"> <asp:TextBox runat="server" ID="txtName" /> <asp:RequiredFieldValidator runat="server" ID="rvalName" ErrorMessage="Error" ControlToValidate="txtName" Display="Dynamic" /> <hr /> <asp:Button runat="server" ID="btnSave" Text="Save" OnClientClick="javascript:PlaySound()" /> <embed src="Resources/Error.wav" autostart="false" width="0" height="0" name="error" enablejavascript="true"></embed> </form> </body> </html>
No comments:
Post a Comment