C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Display Datetime Without Refreshing the page


Posted Date: 07 Aug 2008    Resource Type: Code Snippets    Category: AJAX

Posted By: Ilyas       Member Level: Silver
Rating:     Points: 10



This is an simple code to display the current date and time with out Refreshing the page using Ajax control toolkit


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.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" />
<div>
<asp:Timer runat="server" id="Timer1" interval="1000" ontick="UpdateTime_Tick" />
<asp:UpdatePanel runat="server" id="Panel" updatemode="Conditional">

<Triggers>
<asp:AsyncPostBackTrigger controlid="Timer1" eventname="Tick" />

</Triggers>

<ContentTemplate>
<asp:Label runat="server" id="lbl1" />

</ContentTemplate>

</asp:UpdatePanel>

</div>


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


The code behind C# file for the above .aspx page is given here


protected void UpdateTime_Tick(object sender, EventArgs e)
{
lbl1.Text = DateTime.Now.ToString();
}



The update panel helps us to update partially. Add the timer control to update partially by 1 second.

Ilyas F




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Update Panel with AJAX  .  Update Panel using AJAX  .  Display DateTime without refreshing  .  Display DateTime with AJAX  .  Ajax Update Panel  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Ajax Textbox with AutoComplete feature
Previous Resource: File exist or not in harddisk
Return to Discussion Resource Index
Post New Resource
Category: AJAX


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use