ICLES' Motilal Jhunjhunwala College of Arts, Commerce & Science

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ICLES Motilal Jhunjhunwala College of Arts, Commerce & Science

PRACTICAL NO. 9- Implement the exercise on AJAX


1)

AIM: Create Web application to display time in textbox when user clicks on show Time button.
Implement 2 second delay in between, and within 2 seconds delay display message plz wait for some time..(
using AJAX control).
HTML Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
&nbsp;&nbsp;
<asp:Label ID="Label1" runat="server" ></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Show Time" />
<br />
<br />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:Timer ID="Timer1" runat="server" Enabled="False" Interval="2000"
ontick="Timer1_Tick">
</asp:Timer>
</form>
</body>
</html>
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Collections;
public partial class _Default : System.Web.UI.Page

ICLES Motilal Jhunjhunwala College of Arts, Commerce & Science


{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Wait for 2 seconds";
Timer1.Enabled = true;
}
protected void Timer1_Tick(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString();
Label1.Text = "";
Timer1.Enabled = false;
}
}
OUTPUT SCREEN:

ICLES Motilal Jhunjhunwala College of Arts, Commerce & Science


2)

AIM: Design a web page to visually verify, that the Ajax controls performs partial post back of a page rather
than the full post back unlike the standard control.
HTML Code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
</asp:Timer>
<br />
<asp:Label ID="Label1" runat="server" Text="Panel not refreshed yet"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:Label ID="Label2" runat="server" ></asp:Label>
<br />
</form>
</body>
</html>
CODE:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = "Page last loaded at: " +
DateTime.Now.ToLongTimeString();
}

ICLES Motilal Jhunjhunwala College of Arts, Commerce & Science


protected void Timer1_Tick(object sender, EventArgs e)
{
Label1.Text = "Panel refreshed at: " + DateTime.Now.ToLongTimeString();
}
}
OUTPUT SCREEN:

You might also like