Quick Ajax example using Prototype.js
Overview
UPDATE: Please visit my updated article appropriately named “Quick Ajax Example Using jQuery“.
This example will explain how to use the Prototype.js Javascript library to perform a simple Ajax call from an html page to an ASP.NET page with dynamic info. In this example the dynamic ASP.NET page is getting the current date and time, in a real-world example an ASP.NET page could parse RSS feeds, show stocks quotes, lookup weather, etc.
Requirements
Let’s code!
- Create a web form called
ShowTime.aspx(ShowTime.cswill be auto created) in Visual Studio 2005 and add a label control as shown below: - Open up
ShowTime.csand declare a DateTime type variable and set it to display the current date and time:DateTime dtRightNow = DateTime.Now; - Inside the
Page_Loadset the page to not cache itself with the following code:Response.CacheControl = "no-cache"; - Assign the current date and time to the
lblDateTimecontrol:this.lblDateTime.Text = String.Format("{0:d}", dtRightNow) + " @ " + String.Format("{0:T}", dtRightNow); - Now let’s create
ShowTime.html. This page will call thePrototype.jsand contain some Javascript to make an Ajax call toShowTime.aspx - Between the
tags, reference thePrototype.jsJavascript library like this:. - Now we will write the Javascript that uses
Ajax.UpdaterfromPrototype.js. Below is the code that declares the page containing the dynamic content and the element to output the data when the link is clicked (you could also include the snippet below in a seperate Javascript file). - We're almost done! Just need to ad add a few more things between the
tags. We will add a link with an ID called showtimelink and awith the ID of output.; ;- That's it! View the demo.
Download
- ShowTime.zip (18kb)
Popularity: 39% [?]
Read MoreUsing Log4net in your web apps
Log4net is part of the Apache Logging Services Project. It’s a tool to help ASP.net developers log message to a text file, xml file, email or database.
- Add
log4net.Config.XmlConfigurator.Configure();to Global.asax in theApplication_Startmethod. - In your code-behind or BasePage.cs, declare
protected static readonly ILog logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - Web.config has all the magic.
, , and
To be continued…
Popularity: 7% [?]
Read More - That's it! View the demo.

![[del.icio.us]](http://stevenng.net/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://stevenng.net/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://stevenng.net/wp-content/plugins/bookmarkify/facebook.png)
![[LinkedIn]](http://stevenng.net/wp-content/plugins/bookmarkify/linkedin.png)
![[MySpace]](http://stevenng.net/wp-content/plugins/bookmarkify/myspace.png)
![[StumbleUpon]](http://stevenng.net/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Twitter]](http://stevenng.net/wp-content/plugins/bookmarkify/twitter.png)
![[Windows Live]](http://stevenng.net/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://stevenng.net/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://stevenng.net/wp-content/plugins/bookmarkify/email.png)