Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys here is my code im trying to update a label with a timer tick event in an update panel but it doesnt seem to work or my while loop is broken any help would be appreciated

here is my design and below the code


XML
@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="xp.WebForm1" %>

<!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 id="Head1" runat="server">
    <title></title>
</head>

<body>
    <form id="form1" runat="server">
          <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Timer runat="server" id="UpdateTimer" interval="1000" ontick="UpdateTimer_Tick" />
        <asp:UpdatePanel runat="server" id="TimedPanel" updatemod">
            <Triggers>
                <asp:AsyncPostBackTrigger controlid="UpdateTimer" eventname="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Label runat="server" id="DateStampLabel" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <div>
   <table>
<tr>
<td>
<span style="color: Red">*</span>Attach Excel file
</td>
<td>
<asp:FileUpload ID="fileuploadExcel" runat="server" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnSend" runat="server" Text="Export" onclick="btnSend_Click"  />
</td>
</tr>
</table>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

            </div>
    </form>
</body>
</html>


C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;
using System.Text;
using System.Threading;
using System.Timers;
namespace WebApplication2
{
    public partial class _Default : System.Web.UI.Page
    {

        int Time1 = 1;
        bool maxTime;
        System.Timers.Timer timer1 = new System.Timers.Timer();
        protected void Page_Load(object sender, EventArgs e)
        {
            while (maxTime==true)
            {
                Time1 = Time1 + 1;
            }
        }

        protected void btnSend_Click(object sender, EventArgs e)
        {
            maxTime = true;
            
            <pre lang="cs">Response.Write("hallo");

            maxTime = false;

        }

        protected void UpdateTimer_Tick(object sender, EventArgs e)
        {

            DateStampLabel.Text = Time1.ToString();
            Time1++;
        }
    }
}
Posted
Updated 7-Sep-12 1:23am
v2

1 solution

C#
while (maxTime==true)
{
    Time1 = Time1 + 1;
}


This while loop isn't work at all.Because when your page loads,it don't get any value.so maxTime will not true.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900