Pages

Wednesday, May 13, 2009

Sample Web site using Ajax

Most of the time the user think that how to use the ajax in the application here are the sample application  using the ajax.

you just  need to install the Ajax extention in your application, you can download the Ajax dll from the official site of microsoft asp.net.


In this sample application, i hace taken a label and a button , while clicking on the button the time on the label  is changed but the page does not refreshed, here is the aspx page.




here i had taken the button inside the Update panel, the  main work is done by using this update pannel.

and here is the code for the Cs page..


using System;
using System.Data;
using System.Configuration;
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 _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
            Label1.Text = "Current Time: " + System.DateTime.Now.ToLongTimeString().ToString();
            Label2.Text = "Originally loaded at: " + System.DateTime.Now.ToLongTimeString().ToString();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        
             Label1.Text = "Current Time: " + System.DateTime.Now.ToLongTimeString().ToString();
    
    }
}



Happy Coading

Anil Kumar Pandey
System Architect
Green Point Technology Services (India) Ltd.
Mumbai, Maharastra ,India

Kontera