Timer is available in asp.net toolbox. Double click it to add your page.
Then add Script Manager in our aspx page. Script Manager is Important for timer.
Then add Script Manager in our aspx page. Script Manager is Important for timer.
Design Page
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" interval="1000" ontick="Timer1_Tick">
</asp:Timer>
<asp:Label ID="Label1" runat="server" Text="60"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" interval="1000" ontick="Timer1_Tick">
</asp:Timer>
<asp:Label ID="Label1" runat="server" Text="60"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
Coading
protected void Timer1_Tick(object sender, EventArgs e)
{
if (Convert.ToString(Label1.Text) != "")
{
seconds = int.Parse(Label1.Text);
min = int.Parse(Label1.Text);
}
else
{
seconds =Convert.ToInt32(defaultTimer);//set some time count in default timer
}
Session["timeout"] = (seconds - 1).ToString();
if (seconds > 0)
{
Label1.Text = (seconds + 1).ToString();
}
else
{
Timer1.Enabled = false;
}
}
{
if (Convert.ToString(Label1.Text) != "")
{
seconds = int.Parse(Label1.Text);
min = int.Parse(Label1.Text);
}
else
{
seconds =Convert.ToInt32(defaultTimer);//set some time count in default timer
}
Session["timeout"] = (seconds - 1).ToString();
if (seconds > 0)
{
Label1.Text = (seconds + 1).ToString();
}
else
{
Timer1.Enabled = false;
}
}
No comments:
Post a Comment