G
Guest
I'm trying to follow the instructions on
http://www.asp.net/learn/videos/view.aspx?tabid=63&id=75 for a simple AJAX
demo.
However, my code updates all 3 labels even though only 1 of them is inside
an UpdatePanel. What am I not doing that the presenter is?
Here's the my ASPX and codebehind code..
ASPX
------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SimpleAjax.aspx.cs"
Inherits="Forms_SimpleAjax" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="label1" runat=server></asp:Label> <br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="label2" runat=server></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:Label ID="label3" runat=server></asp:Label>
<br />
<br />
</div>
</form>
</body>
</html>
Codebehind
--------------
public partial class Forms_SimpleAjax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
label2.Text = DateTime.Now.ToString();
label3.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
http://www.asp.net/learn/videos/view.aspx?tabid=63&id=75 for a simple AJAX
demo.
However, my code updates all 3 labels even though only 1 of them is inside
an UpdatePanel. What am I not doing that the presenter is?
Here's the my ASPX and codebehind code..
ASPX
------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SimpleAjax.aspx.cs"
Inherits="Forms_SimpleAjax" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="label1" runat=server></asp:Label> <br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="label2" runat=server></asp:Label>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:Label ID="label3" runat=server></asp:Label>
<br />
<br />
</div>
</form>
</body>
</html>
Codebehind
--------------
public partial class Forms_SimpleAjax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
label2.Text = DateTime.Now.ToString();
label3.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}