This tutorial show you how to set sound timer depend on the number of order. It plays sound for notification whenever the number of order change.
Firstly, copy the following javascript to <head> tage.
![]() |
Sound Timer |
Firstly, copy the following javascript to <head> tage.
<script type="text/javascript"> function EvalSound(soundobj) { var thissound = document.getElementById(soundobj); thissound.play(); } </script>Secondly, copy the following code to <form> tag.
<asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick"> </asp:Timer> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="lblOrder" runat="server" Text=""></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" /> </Triggers> </asp:UpdatePanel> <audio id="audio1" src="sound/Console_beep.mp3" preload="auto" autobuffer> </audio>In code-behind, the following snippet should be there.
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string dt = DateTime.Now.ToLongTimeString(); string count = DAL.GetOrderCount(); lblOrder.Text = string.Format("There are {0} records at {1}.", count, dt); Session["count"] = count; } } protected void Timer1_Tick(object sender, EventArgs e) { string dt = DateTime.Now.ToLongTimeString(); string count = DAL.GetOrderCount(); if (count != Session["count"].ToString()) { lblOrder.Text = string.Format("There are {0} records at {1}.", count, dt); ScriptManager.RegisterStartupScript(Page, GetType(), "PlaySound", "EvalSound('audio1');", true); } Session["count"] = count; }It uses "Northwind" database and connection string in web.config seem like below:
<connectionStrings> <add name="sqlConn" providerName="System.Data.SqlClient" connectionString="Server='(local)';uid='sa';pwd='p@ssw0rd';Database='Northwind';Pooling=False;" /> </connectionStrings>It has the following code snippet in the DAL class. It uses the Microsoft.Practices.EnterpriseLibrary.Data.dll to shorten the code.
private static Database getDatabase() { Database database = null; try { database = DatabaseFactory.CreateDatabase("sqlConn"); } catch (Exception exception) { } return database; } public static string GetOrderCount() { string count = ""; try { count = getDatabase().ExecuteScalar("GetOrderCount").ToString(); } catch (Exception exception) { } return count; }The "GetOrderCount" stored procedure is as shown below:
USE [Northwind] GO ALTER PROCEDURE [dbo].[GetOrderCount] AS BEGIN SELECT COUNT(*) FROM Orders; ENDThis application demonstrates a simple use of the Timer control with UpdatePanel combining HTML5 audio element in a real world example.
Wonderful, just what a blog it is! This blog has provided the helpful data to us continue the good work.
ReplyDeleteindex
Your are welcome!
ReplyDeleteUpdated information about html.Thanks for sharing such a information.
ReplyDeleteselenium training in chennai
I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
ReplyDeleteHadoop Training in Chennai
Personally, I wouldn't go lower than 128kbps for mp3 - and even at that point, things like cymbals or quiet background sounds can have a strange, warbling sound to it. sound of waterfalls
ReplyDeleteThanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. latest naija music
ReplyDeleteThe article is so informative. This is more helpful for our
ReplyDeleteLearn best software testing online certification course class in chennai with placement
Best selenium testing online course training in chennai
Best online software testing training course institute in chennai with placement
Thanks for sharing.
We require all the more such articles that we can read with such excitement.
ReplyDeleteVanessa Martel
Awesome, very interesting to read.Thanks for giving your post :) Kaashiv provides Best DotNet Training in Chennai with professional trainers who provide real-time training and also projects to the candidates for better understanding.
ReplyDeleteOracle Training in Chennai | Android training in chennai | Matlab Training in Chennai | CCNA Training in Chennai
Oh, that's Great Post Thanks for sharing with us.
ReplyDeleteThis Big Data Hadoop Training in Pune Platform helped me to learn advanced concepts of all the trending technologies out there in the current IT market. really worth trying them.
ReplyDeleteOutstanding blog with lots of information. Keep posting more like this.
ccna course in Chennai
ccna institute in Chennai
ccna Training center in Chennai
gst classes in Chennai
ReactJS Training in Chennai
Salesforce Training in Chennai
ccna course in Tambaram
ccna course in Velachery
CCNA course in Vadapalani
Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. Soundcloud downloader
ReplyDelete