What is a ScriptManager in ASP.NET AJAX?
In order to use AJAX functionality on a web page it is required to add a ScriptManager control to the page. ScriptManager control register Microsoft Ajax Library scripts to the web page so we should use the one ScriptManager per page. ScriptManager control enables script to use the type system extensions and to support features like partial-page rendering.
In asp.net web page to add the ScriptManager control, go to the AJAX Extensions tab of the toolbox, double-click the ScriptManager control to add it to the page.
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
Example
When you use the UpdatePanel controls on the web page, the ScriptManeger control manages the partial page rendering means the update the specific portion of the web page. The UpdatePanel control, UpdateProgress control, and Timer control require a ScriptManager control for the partial-page rendering. In the following example you can see that how you can refresh the label control after updating the input value without the page post back event.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" text="Authorcode"/><br /> <asp:Button ID="Button1" runat="server" Text="Change the Text" OnClick="Button1_Click" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>