Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:09:08+00:00 2026-05-29T07:09:08+00:00

I Have the below Asp.net Code: the problem is that When Timer Tick Every

  • 0

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 ?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrdersPage.aspx.cs" Inherits="Orders_" Async="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Gazar | Orders Page</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <link rel="Stylesheet" href="StyleSheet.css" />
    <script type="text/javascript">
        function ShowProgress() {
            document.getElementById('UpdateProgress1').style.display = "inline";
        }
    </script>
</head>
<body>
    <form id="form1" class="center_it" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" EnablePageMethods="true" runat="server"></asp:ToolkitScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
        </Triggers>
        <ContentTemplate>
            <table class="MainTable">
                <tr>
                    <td style="text-align: left;" colspan="2">
                        <img id="Img2" src="~/images/gazzarlogo.png" alt="GazarBanner" runat="server" class="BannerImage" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="30pt" ForeColor="White"
                            Text="الطلبـــــات"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="History" CssClass="Buttons" />
                    </td>
                    <td>
                        <asp:Button ID="Exit" Text="خروج" runat="server" OnClick="Exit_Click" CssClass="Buttons" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="GridViewOrders" runat="server" Style="margin-left: auto; margin-right: auto;"
                            OnRowDataBound="GridViewOrders_RowDataBound" PageSize="30" BackColor="White"
                            BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="0px" CaptionAlign="Top"
                            CellPadding="4" ForeColor="Black" HorizontalAlign="Center" EnableModelValidation="True"
                            GridLines="Vertical" Width="1100px" Font-Names="Tahoma" Font-Size="10pt" Font-Bold="False"
                            OnRowCommand="GridViewOrders_RowCommand" AutoGenerateColumns="False">
                            <RowStyle BackColor="#F7F7DE" Wrap="True" />
                            <AlternatingRowStyle BackColor="White" />
                            <FooterStyle BackColor="#CCCC99" />
                            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Left" />
                            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                            <Columns>
                                <asp:TemplateField HeaderText="Open" ItemStyle-Width="60px">
                                    <ItemTemplate>
                                        <asp:Button ID="ApproveBtn" Text="Open" Width="60" Height="30" runat="server" OnClientClick="ShowProgress()" />
                                    </ItemTemplate>
                                    <ItemStyle Width="70px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ID" ItemStyle-Width="70px">
                                    <ItemTemplate>
                                        <asp:Label ID="OrderID" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "ID") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="70px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Name" ItemStyle-Width="150px">
                                    <ItemTemplate>
                                        <asp:Label ID="Name" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Name") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="150px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Address" ItemStyle-Width="300px">
                                    <ItemTemplate>
                                        <asp:Label ID="Address" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Address") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="300px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Number" ItemStyle-Width="100px">
                                    <ItemTemplate>
                                        <asp:Label ID="Number" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Number") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sent Date" ItemStyle-Width="100px">
                                    <ItemTemplate>
                                        <asp:Label ID="SentDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Sent Date") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Recieved Date" ItemStyle-Width="100px">
                                    <ItemTemplate>
                                        <asp:Label ID="RecievedDate" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Recieved Date") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="# Success" ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:Label ID="SuccessNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Success") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="# Fake" ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:Label ID="FakeNo" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "# Fake") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Restaurant" ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:Label ID="Restaurant" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Restaurant") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Branch" ItemStyle-Width="50px">
                                    <ItemTemplate>
                                        <asp:Label ID="Branch" CommandName="Select" runat="server" Text='<% #DataBinder.Eval(Container.DataItem, "Branch") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="50px" />
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <div class="container">
                <div class="LoadingDiv">
                    <span class="LoadingLabel">Check Orders ...</span>
                    <img class="LoadingImg" src="Images/ajax-loader.gif" alt="Loading ..." />
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:Timer ID="Timer1" runat="server" Interval="30000" OnTick="Timer1_Tick" />
    </form>
</body>
</html>

and code behind is:

protected void Timer1_Tick(object sender, EventArgs e)

       {
            orderDB.LogState("Time Tick");
            if (Session["UserID"] != null)
            {
                orderDB.LogState("Session Alive");
                FillDataGrid(int.Parse(Session["UserID"].ToString()));
                orderDB.LogState("End fill Grid View");
            }
            else
            {
                Response.Redirect("~/login.aspx");
            }
        }

private void FillDataGrid(int UserID)
{

    Orders = orderDB.GetOrdersByUser(UserID);
    orderDB.LogState("Select: " + DateTime.Now.ToString() + "\t" + Request.UserHostAddress + "\t" + Session.SessionID + "\t" + Session["UserID"].ToString());

    if (Orders == null)
        Response.Redirect("~/login.aspx");

    DataTable Table = new DataTable();

    Table.Columns.Add("ID", System.Type.GetType("System.String"));
    Table.Columns.Add("Name", System.Type.GetType("System.String"));
    Table.Columns.Add("Address", System.Type.GetType("System.String"));
    Table.Columns.Add("Number", System.Type.GetType("System.String"));
    Table.Columns.Add("Sent Date", System.Type.GetType("System.String"));
    Table.Columns.Add("Recieved Date", System.Type.GetType("System.String"));
    Table.Columns.Add("# Success", System.Type.GetType("System.String"));
    Table.Columns.Add("# Fake", System.Type.GetType("System.String"));
    Table.Columns.Add("Restaurant", System.Type.GetType("System.String"));
    Table.Columns.Add("Branch", System.Type.GetType("System.String"));

    for (int i = 0; i < Orders.Count; i++)
    {
        object[] myRow = new object[10];
        myRow[0] = Orders[i].GetId();
        myRow[1] = Orders[i].GetOwner();
        myRow[2] = Orders[i].GetAddress().getAllAddress();
        myRow[3] = Orders[i].GetPhoneNumber();
        myRow[4] = Orders[i].GetOriginalTime().ToString();
        myRow[5] = Orders[i].GetTime().ToString();
        myRow[6] = Orders[i].NoOfSuccess; //success Orders;
        myRow[7] = Orders[i].NoOfFake; //fake Orders
        myRow[8] = Orders[i].GetResName();
        myRow[9] = Orders[i].GetBranchName();

        Table.Rows.Add(myRow);
    }

    orderDB.LogState("Table Rows Count: " + Table.Rows.Count);
    GridViewOrders.DataSource = Table;
    GridViewOrders.DataBind();

    string sSelectedAudio = Server.MapPath("home.wav");
    if (GridViewOrders.Rows.Count != 0)
    {
        playSound(sSelectedAudio);
        orderDB.LogState("Sound Played: " + GridViewOrders.Rows.Count);
    }
    else
    {
        orderDB.LogState("Empty Grid View: " + GridViewOrders.Rows.Count);
    }
}

private void playSound(string path)
{
    string PlaySound = "<embed src=\"" + path + "\" autostart=\"true\" hidden=\"true\"></embed>";
    Response.Write(PlaySound);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:09:08+00:00Added an answer on May 29, 2026 at 7:09 am

    It could be the Response.Write that’s causing the issue. Try using a placeholder control then adding a HtmlGenericControl to it with the markup for the embed tag i.e.

     HtmlGenericControl sound = new HtmlGenericControl("<embed src=\"" + path + "\" 
               autostart=\"true\" hidden=\"true\"></embed>");
        ucPlaceHolder.Controls.Add(sound);
    

    Make sure the placeholder control is withing the ContentTemplate of the UpdatePanel that you are using

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Jquery Accordion and I have a asp.net GridView below that. When
I've an annoying ASP.NET problem: I have a Perl script (see below), which gets
I have code below: <select id=testSelect> <option value=1>One</option> <option value=2>Two</option> </select> <asp:Button ID=btnTest runat=server
I have a gridview like below: <asp:GridView DataKeyNames=TransactionID AllowSorting=True AllowPaging=TrueID=grvBrokerage runat=server AutoGenerateColumns=False CssClass=datatable Width=100%
I have a ASP.NET Web Forms application that internally makes many SOAP and REST
I have a rather simple problem with ASP.NET. I have a grid view with
I am using asp.net mvc 2.0(default binding model) and I have this problem. I
The particular problem is one that have been asked before. I've got an asp:chart
I have an ASP.NET website on a Windows 2003 Server, that needs to access
I am a newbie in using asp.net, I have a problem on how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.