A Sample Program for Ajax

The current code will look like ordinary ASP.NET, with a few new web controls. The markup: Using ASP.NET AJAX Enabled Website

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Hello, world!</title>

</head>

<body>

    <form id="form1" runat="server">

        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <asp:UpdatePanel runat="server" id="HelloWorldPanel">

        <ContentTemplate>

            <asp:Button runat="server" id="SayHelloButton" text="Hello, world!" onclick="SayHelloButton_Click" />

            <br /><br />

            <asp:Label runat="server" id="HelloWorldLabel" />

        </ContentTemplate>

        </asp:UpdatePanel>

    </form>

</body>

</html>

In the CodeBehind, there's nothing new except for this event which you should add:

protected void SayHelloButton_Click(object sender, EventArgs e)

{

    HelloWorldLabel.Text = "Hello, world! A random number: " + new Random().Next().ToString();

}