ASP.NET AJAX consists of client-script libraries and server components that are integrated to provide a robust development framework, which allow us to build rich client applications quickly and easily.
Whenever a postback happens in a normal ASP.NET page the whole ASP.NET page will be refreshed. But AJAX Enabled ASP.NET web page will enable partial rendering of a web page as the result of an asynchronous postback.
Creating a Basic AJAX Web Form declaratively is very easy and looks like code bellow:
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form2" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<asp:ScriptReference Path="clientscript.js" />
</Scripts>
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button2" runat="server" Text="Button" />
</form>
</body>
</html>
But, in Some situations we need to create some of the Web Controls which make the AJAX Web Form dynamically at runtime. in these scenario's we need to follow some basic steps.