Click here to Skip to main content
15,892,737 members
Articles / Web Development / XHTML

(Re) Introducing AJAX for ASP.NET with Prototype

Rate me:
Please Sign up or sign in to vote.
4.90/5 (16 votes)
17 Dec 2008CPOL10 min read 60.7K   449   47  
Writing and using cross platform AJAX in ASP.NET applications.
<%@ Page Language="C#"%>

<!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>
    <title>Untitled Page</title>
    <script src="../js/prototype.js" type="text/javascript"></script>
    <style type="text/css" media="screen">
      #quote {
        color: green; 
        font-size:small;
        border: 1px solid #cfc;
        padding: 5px 0 5px 40px;
        font-family: Verdana, Arial, Helvetica, sans-serif; 
      }
      input.button 
      {
      	padding: 2px 5px;
      	border-width:1px;
      	color:Green;
      	border-style: solid;
      }
      	
    </style> 
</head>
<body>
<div id="quote"></div>
<p>
<input type="button" onclick="stopPolling()" value="Stop Ajax" class="button" />&nbsp;
<input type="button" onclick="startPolling()" value="Start Ajax" class="button" />
    
<script language="javascript" type="text/javascript" >
var poller;

poller = new Ajax.PeriodicalUpdater('quote', 'QuoteScript.aspx', {
  method: 'get', frequency: 5
});

function stopPolling() {
  poller.stop();
  $(quote).innerHTML = "Asynchronous JavaScript Stopped";
}

function startPolling() {
  poller.start();
}

</script>
</body> 
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I'm a professional .NET software developer and proud military veteran. I've been in the software business for 20+ years now and if there's one lesson I have learned over the years, its that in this industry you have to be prepared to be humbled from time to time and never stop learning!

Comments and Discussions