Ajax Basics

There are five controls in Ajax, those are

  • ScriptManager
  • Script ManagerProxy
  • UpdatePanel
  • Updateprogress
  • Timer
ScriptManager : This is main control. This control should be there in the page if you want to use ajax function for your page.

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnableScriptGlobalization="true" EnableScriptLocalization="true">
        </asp:ScriptManager>

To use the Ajax function for Gridview

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AllowSorting="True" CellPadding="4" CssClass="Grid" DataKeyNames="customerID" 
            EmptyDataText="N/A" ShowFooter="True" AutoGenerateColumns="False" 
            EnableModelValidation="True" ForeColor="#333333" GridLines="None"  >
            <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:TemplateField HeaderText="CustomerID" SortExpression="CustomerID">
                <ItemTemplate>
                    <asp:LinkButton ID="lnkcustID" runat="server" CommandArgument='<%# Eval("CustomerID") %>' CommandName="CustomerID" Text='<%# Eval("CustomerID") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="Custname" SortExpression="Custname" HeaderText="Customer Name" />
            <asp:BoundField DataField="CustAddr" SortExpression="CustAddr" HeaderText="Customer Address" />
            <asp:BoundField DataField="CustPh" SortExpression="CustPh" HeaderText="Customer Phone" />
            <asp:BoundField DataField="CustLoc" SortExpression="CustLoc" HeaderText="Customer Location" />
        </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerSettings Mode="Numeric" Position="TopAndBottom"  />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle HorizontalAlign="Left" CssClass="Gridrow" BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        </asp:GridView>
        </ContentTemplate>
        </asp:UpdatePanel>


To use Progress control



<asp:UpdateProgress ID="UpdateProgress1" runat="server" >
<ProgressTemplate>
   Loading....
 </ProgressTemplate>
 </asp:UpdateProgress>



<asp:Timer ID="Timer1" runat="server" Interval="100" >
        </asp:Timer>