var tim; var sec = document.getElementById("ddlTime").value; function f2() { if (parseInt(sec) > 0) { sec = parseInt(sec) - 1; document.getElementById("lblTimer").innerHTML = "Left Time :" + sec +" Seconds"; tim = setTimeout("f2()", 1000); //return false; } else { clearTimeout(tim); document.getElementById('btnSubmit').click(); //return false; } return false; }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><title>Untitled Page <div> <asp:Label ID="lblTimer" runat="server" Font-Bold="True" Font-Names="Agency FB" Font-Size="X-Large" ForeColor="DarkBlue" Style="z-index: 100; left: 371px; position: absolute; top: 52px" Text="TIMER" Width="140px"> <asp:Button ID="btnStart" runat="server" OnClientClick="return f2();" OnClick="btnStart_Click" Style="z-index: 101; left: 365px; position: absolute; top: 127px" Text="Start" /> <asp:Button ID="btnSubmit" runat="server" Style="z-index: 105; left: 359px; position: absolute; top: 264px" Text="Submit" OnClick="btnSubmit_Click" /> <asp:Label ID="Label1" runat="server" Style="z-index: 103; left: 76px; position: absolute; top: 173px" Text="Label"> <asp:DropDownList ID="ddlTime" runat="server" AutoPostBack="True" Font-Size="Large" Style="z-index: 104; left: 279px; position: absolute; top: 51px" Width="61px"> <asp:listitem>10 <asp:listitem>180 <asp:listitem>300 <asp:listitem>600 </div>
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class Default1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnStart_Click(object sender, EventArgs e) { Label1.Text = "Sta!!"; } protected void btnSubmit_Click(object sender, EventArgs e) { lblTimer.Text = "Time Out"; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)