473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Play Sound Using Javascript with UpdatePanel

I Have the below Asp.net Code:

the problem is that When Timer Tick Every 30 Second and GridView Filled the javascript code is not executed !! and Sound is not played.

I have also tried SoundPlayer Class but is not working on the Server Side can anyone provide me with a solution ?

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrdersPage.aspx.cs" Inherits="Orders_" Async="true" %>
  2.  
  3. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7.     <title>Gazar | Orders Page</title>
  8.     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
  9.     <link rel="Stylesheet" href="StyleSheet.css" />
  10.     <script type="text/javascript">
  11.         function ShowProgress() {
  12.             document.getElementById('UpdateProgress1').style.display = "inline";
  13.         }
  14.     </script>
  15. </head>
  16. <body>
  17.     <form id="form1" class="center_it" runat="server">
  18.     <asp:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePageMethods="true" runat="server"></asp:ToolkitScriptManager>
  19.     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  20.         <Triggers>
  21.             <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
  22.         </Triggers>
  23.         <ContentTemplate>
  24.             <table class="MainTable">
  25.                 <tr>
  26.                     <td style="text-align: left;" colspan="2">
  27.                         <img id="Img2" src="~/images/gazzarlogo.png" alt="GazarBanner" runat="server" class="BannerImage" />
  28.                     </td>
  29.                 </tr>
  30.                 <tr>
  31.                     <td colspan="2">
  32.                         <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="30pt" ForeColor="White"
  33.                             Text="الطلبـــــات"></asp:Label>
  34.                     </td>
  35.                 </tr>
  36.                 <tr>
  37.                     <td>
  38.                         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="History" CssClass="Buttons" />
  39.                     </td>
  40.                     <td>
  41.                         <asp:Button ID="Exit" Text="خروج" runat="server" OnClick="Exit_Click" CssClass="Buttons" />
  42.                     </td>
  43.                 </tr>
  44.                 <tr>
  45.                     <td colspan="2">
  46.                         <asp:GridView ID="GridViewOrders" runat="server" Style="margin-left: auto; margin-right: auto;"
  47.                             OnRowDataBound="GridViewOrders_RowDataBound" PageSize="30" BackColor="White"
  48.                             BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="0px" CaptionAlign="Top"
  49.                             CellPadding="4" ForeColor="Black" HorizontalAlign="Center" EnableModelValidation="True"
  50.                             GridLines="Vertical" Width="1100px" Font-Names="Tahoma" Font-Size="10pt" Font-Bold="False"
  51.                             OnRowCommand="GridViewOrders_RowCommand" AutoGenerateColumns="False">
  52.                             <RowStyle BackColor="#F7F7DE" Wrap="True" />
  53.                             <AlternatingRowStyle BackColor="White" />
  54.                             <FooterStyle BackColor="#CCCC99" />
  55.                             <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Left" />
  56.                             <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
  57.                             <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
  58.                             <Columns>
  59.                                 <asp:TemplateField HeaderText="Open" ItemStyle-Width="60px">
  60.                                     <ItemTemplate>
  61.                                         <asp:Button ID="ApproveBtn" Text="Open" Width="60" Height="30" runat="server" OnClientClick="ShowProgress()" />
  62.                                     </ItemTemplate>
  63.                                     <ItemStyle Width="70px" />
  64.                                 </asp:TemplateField>
  65.                                 <asp:TemplateField HeaderText="ID" ItemStyle-Width="70px">
  66.                                     <ItemTemplate>
  67.                                         <asp:Label ID="OrderID" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "ID") %>'></asp:Label>
  68.                                     </ItemTemplate>
  69.                                     <ItemStyle Width="70px" />
  70.                                 </asp:TemplateField>
  71.                                 <asp:TemplateField HeaderText="Name" ItemStyle-Width="150px">
  72.                                     <ItemTemplate>
  73.                                         <asp:Label ID="Name" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
  74.                                     </ItemTemplate>
  75.                                     <ItemStyle Width="150px" />
  76.                                 </asp:TemplateField>
  77.                                 <asp:TemplateField HeaderText="Address" ItemStyle-Width="300px">
  78.                                     <ItemTemplate>
  79.                                         <asp:Label ID="Address" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Address") %>'></asp:Label>
  80.                                     </ItemTemplate>
  81.                                     <ItemStyle Width="300px" />
  82.                                 </asp:TemplateField>
  83.                                 <asp:TemplateField HeaderText="Number" ItemStyle-Width="100px">
  84.                                     <ItemTemplate>
  85.                                         <asp:Label ID="Number" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Number") %>'></asp:Label>
  86.                                     </ItemTemplate>
  87.                                     <ItemStyle Width="100px" />
  88.                                 </asp:TemplateField>
  89.                                 <asp:TemplateField HeaderText="Sent Date" ItemStyle-Width="100px">
  90.                                     <ItemTemplate>
  91.                                         <asp:Label ID="SentDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Sent Date") %>'></asp:Label>
  92.                                     </ItemTemplate>
  93.                                     <ItemStyle Width="100px" />
  94.                                 </asp:TemplateField>
  95.                                 <asp:TemplateField HeaderText="Recieved Date" ItemStyle-Width="100px">
  96.                                     <ItemTemplate>
  97.                                         <asp:Label ID="RecievedDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Recieved Date") %>'></asp:Label>
  98.                                     </ItemTemplate>
  99.                                     <ItemStyle Width="100px" />
  100.                                 </asp:TemplateField>
  101.                                 <asp:TemplateField HeaderText="# Success" ItemStyle-Width="50px">
  102.                                     <ItemTemplate>
  103.                                         <asp:Label ID="SuccessNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Success") %>'></asp:Label>
  104.                                     </ItemTemplate>
  105.                                     <ItemStyle Width="50px" />
  106.                                 </asp:TemplateField>
  107.                                 <asp:TemplateField HeaderText="# Fake" ItemStyle-Width="50px">
  108.                                     <ItemTemplate>
  109.                                         <asp:Label ID="FakeNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Fake") %>'></asp:Label>
  110.                                     </ItemTemplate>
  111.                                     <ItemStyle Width="50px" />
  112.                                 </asp:TemplateField>
  113.                                 <asp:TemplateField HeaderText="Restaurant" ItemStyle-Width="50px">
  114.                                     <ItemTemplate>
  115.                                         <asp:Label ID="Restaurant" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Restaurant") %>'></asp:Label>
  116.                                     </ItemTemplate>
  117.                                     <ItemStyle Width="50px" />
  118.                                 </asp:TemplateField>
  119.                                 <asp:TemplateField HeaderText="Branch" ItemStyle-Width="50px">
  120.                                     <ItemTemplate>
  121.                                         <asp:Label ID="Branch" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Branch") %>'></asp:Label>
  122.                                     </ItemTemplate>
  123.                                     <ItemStyle Width="50px" />
  124.                                 </asp:TemplateField>
  125.                             </Columns>
  126.                         </asp:GridView>
  127.                     </td>
  128.                 </tr>
  129.             </table>
  130.         </ContentTemplate>
  131.     </asp:UpdatePanel>
  132.     <asp:UpdateProgress ID="UpdateProgress1" runat="server">
  133.         <ProgressTemplate>
  134.             <div class="container">
  135.                 <div class="LoadingDiv">
  136.                     <span class="LoadingLabel">Check Orders ...</span>
  137.                     <img class="LoadingImg" src="Images/ajax-loader.gif" alt="Loading ..." />
  138.                 </div>
  139.             </div>
  140.         </ProgressTemplate>
  141.     </asp:UpdateProgress>
  142.     <asp:Timer ID="Timer1" runat="server" Interval="30000" OnTick="Timer1_Tick" />
  143.     </form>
  144. </body>
  145. </html>
  146.  
and code behind is:

Expand|Select|Wrap|Line Numbers
  1. protected void Timer1_Tick(object sender, EventArgs e)
  2.  
  3.        {
  4.             orderDB.LogState("Time Tick");
  5.             if (Session["UserID"] != null)
  6.             {
  7.                 orderDB.LogState("Session Alive");
  8.                 FillDataGrid(int.Parse(Session["UserID"].ToString()));
  9.                 orderDB.LogState("End fill Grid View");
  10.             }
  11.             else
  12.             {
  13.                 Response.Redirect("~/login.aspx");
  14.             }
  15.         }
  16.  
  17. private void FillDataGrid(int UserID)
  18. {
  19.  
  20.     Orders = orderDB.GetOrdersByUser(UserID);
  21.     orderDB.LogState("Select: " + DateTime.Now.ToString() + "\t" + Request.UserHostAddress + "\t" + Session.SessionID + "\t" + Session["UserID"].ToString());
  22.  
  23.     if (Orders == null)
  24.         Response.Redirect("~/login.aspx");
  25.  
  26.     DataTable Table = new DataTable();
  27.  
  28.     Table.Columns.Add("ID", System.Type.GetType("System.String"));
  29.     Table.Columns.Add("Name", System.Type.GetType("System.String"));
  30.     Table.Columns.Add("Address", System.Type.GetType("System.String"));
  31.     Table.Columns.Add("Number", System.Type.GetType("System.String"));
  32.     Table.Columns.Add("Sent Date", System.Type.GetType("System.String"));
  33.     Table.Columns.Add("Recieved Date", System.Type.GetType("System.String"));
  34.     Table.Columns.Add("# Success", System.Type.GetType("System.String"));
  35.     Table.Columns.Add("# Fake", System.Type.GetType("System.String"));
  36.     Table.Columns.Add("Restaurant", System.Type.GetType("System.String"));
  37.     Table.Columns.Add("Branch", System.Type.GetType("System.String"));
  38.  
  39.     for (int i = 0; i < Orders.Count; i++)
  40.     {
  41.         object[] myRow = new object[10];
  42.         myRow[0] = Orders[i].GetId();
  43.         myRow[1] = Orders[i].GetOwner();
  44.         myRow[2] = Orders[i].GetAddress().getAllAddress();
  45.         myRow[3] = Orders[i].GetPhoneNumber();
  46.         myRow[4] = Orders[i].GetOriginalTime().ToString();
  47.         myRow[5] = Orders[i].GetTime().ToString();
  48.         myRow[6] = Orders[i].NoOfSuccess; //success Orders;
  49.         myRow[7] = Orders[i].NoOfFake; //fake Orders
  50.         myRow[8] = Orders[i].GetResName();
  51.         myRow[9] = Orders[i].GetBranchName();
  52.  
  53.         Table.Rows.Add(myRow);
  54.     }
  55.  
  56.     orderDB.LogState("Table Rows Count: " + Table.Rows.Count);
  57.     GridViewOrders.DataSource = Table;
  58.     GridViewOrders.DataBind();
  59.  
  60.     string sSelectedAudio = Server.MapPath("home.wav");
  61.     if (GridViewOrders.Rows.Count != 0)
  62.     {
  63.         playSound(sSelectedAudio);
  64.         orderDB.LogState("Sound Played: " + GridViewOrders.Rows.Count);
  65.     }
  66.     else
  67.     {
  68.         orderDB.LogState("Empty Grid View: " + GridViewOrders.Rows.Count);
  69.     }
  70. }
  71.  
  72. private void playSound(string path)
  73. {
  74.     string PlaySound = "<embed src=\"" + path + "\" autostart=\"true\" hidden=\"true\"></embed>";
  75.     Response.Write(PlaySound);
  76. }
  77.  
Feb 3 '12 #1
0 1851

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: yuen | last post by:
How to play sound by C# without using WMP?
1
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be"...
10
by: CM | last post by:
Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As...
1
by: pkoziejko | last post by:
Hi! I have implemented psychoacustic Johnson model for wav files, and now I need to play data after modification. Now I have only playing *.wav using and PlaySound( "wav_file.wav",...
2
by: Gandalf | last post by:
I need to create sound with Javascript. Until now all the code I have been trying doesn't work width Firefox. can some one please show me how to do it, or give me a link to a good article? ...
1
by: tinmaung | last post by:
hi please help me i want to know how to play sound in java application i don't mean java applet if you can, please send me how to write coding to play sound in application.
6
by: gobblegob | last post by:
Hi guys, I am playing a sound using MMC on a form that pops up. Ok here is the problem it plays fine the first time but when the form loads the second time it plays no sound. Private Sub...
26
by: Jake Barnes | last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching for "how to play a sound with Javascript". I'm somewhat suprised that the majority of entries are from the 1990s, and there are...
3
by: jamessarvs | last post by:
Windows Media Player cannot play the file because there is a problem with your sound device. There might not be a sound device installed on your computer, it might be in use by another program, or it...
1
by: nicolecastel | last post by:
Hello I want to play sound in three external sound cards at the same time,I mean when I click in a button I can hear sound from three speakers which are related to my three sound cards. I have a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.