ScriptManager Example in ASP.NET using C#

ScriptManager Example in ASP.NET using C#

Posted in : ASP.Net Posted on : December 15, 2010 at 5:49 PM Comments : [ 0 ]

In this article we will introduce with ScriptManager control in ASP.NET using C#.

ScriptManager Example in ASP.NET using C#

ScriptManager is used in ASP.NET for using AJAX controls. It serves as the bridge between the client page and the Ajax Framework. In this example we use UpdatePanel and a button when you will click on update time button it will show the current time. The syntax of ScriptManager are following:

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

ScriptManager.aspx (Design Page):

ScriptManager.aspx (source code):

<%@ Page Title="" Language="C#" MasterPageFile="~/RoseindiaMaster.master" AutoEventWireup="true"
CodeFile="ScriptManager.aspx.cs" Inherits="ScriptManager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<h2 style="color: Green">
ScriptManager in ASP.NET 4, C#</h2>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Button runat="server" ID="Button1" Text="Update Time" 
OnClick="Button1_Click" Width="118px" />
<br />
<br />
<asp:Label runat="server" ID="Label1" Font-Bold="True" Font-Names="Cambria" 
Font-Size="X-Large" ForeColor="#CC0000" />

ScriptManager.aspx.cs (C# code file):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ScriptManager : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
Label1.Text = "Current Time : " + System.DateTime.Now.ToLongTimeString();


When you will run the application it will show just like that.

Now when you click the update time button it will show the current time.

Download source code
Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics