1.11M Members

Timer is working offline fine.. but online its not working

 
0
 
 protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            UpdateTime();

        }

    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        UpdateTime();
    }
    public void UpdateTime()
    {
        try
        {
            int hour = 00, min = 00, sec = Int32.Parse(Session["tleft"].ToString());
            // min = Int32.Parse(Session["tleft"].ToString()) / 
            TimeSpan span = new TimeSpan(TimeSpan.TicksPerSecond * sec);
            string str = span.Hours.ToString("00") + ":" + span.Minutes.ToString("00") + ":" + span.Seconds.ToString("00");

            int tleft = Int32.Parse(Session["tleft"].ToString()) - 1;
            if (tleft <= 0)
            {
                Response.Redirect("result.aspx");
            }

            // timeleft.Text = tleft.ToString();
            timeleft.Text = str.ToString();
            Session["tleft"] = tleft.ToString();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }

    -----------------------------------------------------------------------

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

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" >
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div>
        <asp:Label ID="timeleft" runat="server" ></asp:Label>
        <asp:Timer ID="Timer1" Enabled="true"  runat="server" Interval="1000" 
            ontick="Timer1_Tick" >
        </asp:Timer>
    </div>

    </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Timer1" />
        </Triggers>
    </asp:UpdatePanel>
    </form>
</body>
</html>
 
0
 

You need to provide more information. What isn't working? What error messages to you see? Are you sure the "online" environment is supporting ASP.NET?

 
0
 

yes online environment is supporting asp.net 2008. it doesnot show any error. please check http://www.testuonline.com. I dont know why timer is not ticking when i upload it on the online server. but timer is ticking fine when the page runs offline on my system.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: