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


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




timer Control


Posted Date: 11 Oct 2008      Total Responses: 1

Posted By: Vidhi Suri       Member Level: Bronze     Points: 1


how do I add a time which could be shown to the user in case if an application which requires a user to take a test so the remaining time should be shown to the user, in case of an ASP application.
pleasev reply fast.




Responses

Author: Antony s Nasarath    11 Oct 2008Member Level: SilverRating:     Points: 6
You can use asp.net with Ajax to do this. For this you should need visual studio 2005 or higher.

If you are using VS 2005, you should create Ajax enable web site.

1. Add script manager to web form
2.Add update panel and add the contant you want, in this case i added a lable and timer.
3.Add asynchoronus trigger to handle tick event of timer control.
4.Create timer tick event and add code to display in the lable control

Code sample
<!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>Test site</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>

</asp:UpdatePanel>

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

Timer click event

protected void Timer1_Tick(object sender, EventArgs e)
{
this.Label1.Text = DateTime.Now.ToString();
}

In timer proper you should enable timer and set interval to trigger every minut (60000 mill sec).

In the example above, timer event update timer every minute.

Regards,
Antony



Post Reply
You must Sign In to post a response.
Next : use substring function in javacript
Previous : help is label
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use