Tuesday, February 14, 2012

Java Script timer Example in ASP.Net


Timer is used to fire certain action after a certain time period



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

<!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>Untitled Page</title>
   
    <script language=javascript>

function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
alert("Hello");
}        
 
    </script>
   
   
</head>
<body>
    <form id="form1">
    <div>
   
   
    <input id="Button1" type="button" value="Click me to display message" onclick="timeMsg()" />
  
    </div>
    </form>
</body>
</html>

1 comment:

  1. Confusion, it's javascript, not Java Script !

    ReplyDelete