Al Pascual



Geo RSS
Geo Twitter Timeline

Blogs I read

<January 2009>
SunMonTueWedThuFriSat
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Code Snip "AJAX Timer"

 Tired of receiving the same email, this is the code for the timer. Normal mistake, people sets the timer outside the UpdatePanel

<

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" />

 

<div>

 

&nbsp;<asp:UpdatePanel ID="UpdatePanel1" runat="server">

 

<ContentTemplate>

 

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

 

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

 

<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">

 

</asp:Timer>

 

</ContentTemplate>

 

 

</asp:UpdatePanel>

 

 

</div>

 

</form>

</

body>

</

html>

 

 

protected void Page_Load(object sender, EventArgs e)

{

 

if (!Page.IsPostBack)

Label1.Text =

"Timer will run every 5 seconds to display the time in an Update Panel";

}

 

protected void Timer1_Tick(object sender, EventArgs e)

{

Label1.Text =

DateTime.Now.ToString();

}

kick it on DotNetKicks.com

Comments

TrackBack said:

# December 22, 2006 2:42 PM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# December 22, 2006 9:52 PM

ujjwal b soni said:

Hi, The article is very nice !!! Regards, Ujjwal B Soni
# September 15, 2008 2:57 AM