Sunday, October 10, 2010

How to play a sound on error


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:0margin: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:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...