Saturday, July 9, 2011

How to set timer control in your asp.net web application

1.Download ajaxControl.dll from google which is free dll.
2.Add that dll to your reference in the sample web project in Visual studio.net.
3.Drag that dll to your toolbox and once it is done you can find some ajax controls.
4.Drag the timer control onto your webpage.
5.Open design page i.e. html page.In that write the below code as follow



<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer id="Timer1" runat="server" OnTick="Timer1_Tick" Interval="3000"></asp:Timer>
<center>
<h1>
<asp:TextBox id="txtTimer" runat="server"></asp:TextBox>
</h1>
</center>
</ContentTemplate>
</asp:UpdatePanel>
</div>

2. In the page_Load write the below code

protected void Timer1_Tick(object sender, EventArgs e)
{
txtTimer.visible = false;
}