<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SubmissionThrottlingDemo.aspx.cs" Inherits="AJAX.SubmissionThrottlingDemo" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>AJAX Design Pattern: Submission Throttling</title>
<style type="text/css">
#Text1
{
z-index: 1;
left: 92px;
top: 169px;
position: absolute;
width: 240px;
}
#txtName
{
z-index: 1;
left: 76px;
top: 168px;
position: absolute;
width: 153px;
}
</style>
<script type="text/javascript" >
var timer;
var count = 0;
function init() {
//set a
timer to call the convertName function in 3 seconds
//timer
= setTimeout("convertName()", 3000);
timer = setInterval("convertName()", 3000);
}
function uninit() {
//stop
the timer
//clearTimeout(timer);
clearInterval(timer);
alert("timer cleared");
}
function convertName() {
count++;
// make
an async request to convert the letters in the
textbox
AJAX.AJAXWebService.ConvertName(document.getElementById("txtName").value,
onCompleteName);
//init();
}
function onCompleteName(data) {
document.getElementById("display_area").innerHTML = data + " [ " + count
+ "]";
}
</script>
</head>
<body bgcolor="#669999">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/AJAXWebService.asmx" />
</Services>
</asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Font-Size="24pt"
Text="Design Pattern:
Submission Throttling Demo"></asp:Label>
<br />
<br />
<div id="display_area"></div>
<br />
<br />
<asp:Label ID="Label2" runat="server"
style="z-index: 1; left: 12px; top: 169px; position: absolute; bottom: 428px; width: 84px"
Text="Name: " Font-Size="14pt"></asp:Label>
<br />
<br />
<br />
<br />
<input id="txtName" type="text" onfocus="init();" onblur="uninit()" />
<br />
<br />
<br />
</div>
</form>
<p>
</p>
</body>
</html>