看了TerryLeeAtlas学习手记系列 ,自己动手做了第一个Demo。(太简单了,不适合放在这里 可以删调 ^_^)
环境:VS 2005 并安装了AtlasSetup.msi 关于AtlasSetup.msi的下载地址在我的首页下载连接中有。
CS代码
public partial class UpdatePanel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = this.DropDownList1.SelectedValue;
this.Label2.Text = this.DropDownList2.SelectedValue;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.Label3.Text == "我是A!")
{
this.Label3.Text = "我是B,我怎么来这了?";
}
else
{
this.Label3.Text = "我是A!";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (this.Label4.Text == "我是B!")
{
this.Label4.Text = "我是A,我怎么来这儿了?";
}
else
{
this.Label4.Text = "我是B!";
}
}
}
public partial class UpdatePanel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = this.DropDownList1.SelectedValue;
this.Label2.Text = this.DropDownList2.SelectedValue;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.Label3.Text == "我是A!")
{
this.Label3.Text = "我是B,我怎么来这了?";
}
else
{
this.Label3.Text = "我是A!";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
if (this.Label4.Text == "我是B!")
{
this.Label4.Text = "我是A,我怎么来这儿了?";
}
else
{
this.Label4.Text = "我是B!";
}
}
}
HTML代码
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>
<div id="DIV1" runat="server">
<table style="width: 404px; height: 161px" cellspacing=3 border=0 bgcolor=909090>
<tr bgcolor=e6e6e6>
<td style="width: 101px">
我就不刷新:</td>
<td style="width: 73px">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="100px">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="轻轻的呼唤" /></td>
<td style="width: 100px">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Always">
<Triggers>
<atlas:ControlValueTrigger ControlID="DropDownList1" PropertyName="SelectedValue"/>
</Triggers>
<ContentTemplate>
您选中了:<asp:Label ID="Label1" runat="server" Width="69px" Font-Bold="True" ForeColor="Red"></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdatePanel ID="UpdatePanel2" runat="server" Mode="Always">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="我是A!"></asp:Label>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="Button1" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
</td>
</tr>
<tr bgcolor=e6e6e6>
<td style="width: 101px">
我怎么总刷:</td>
<td style="width: 73px">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" Width="94px">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="给我使劲喊" /></td>
<td style="width: 100px">
您选中了:<br/><asp:Label ID="Label2" runat="server" Text="Label" ForeColor="Red"></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text="我是B!"></asp:Label></td>
</tr>
</table>
<br />
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>
<div id="DIV1" runat="server">
<table style="width: 404px; height: 161px" cellspacing=3 border=0 bgcolor=909090>
<tr bgcolor=e6e6e6>
<td style="width: 101px">
我就不刷新:</td>
<td style="width: 73px">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" Width="100px">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="轻轻的呼唤" /></td>
<td style="width: 100px">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Always">
<Triggers>
<atlas:ControlValueTrigger ControlID="DropDownList1" PropertyName="SelectedValue"/>
</Triggers>
<ContentTemplate>
您选中了:<asp:Label ID="Label1" runat="server" Width="69px" Font-Bold="True" ForeColor="Red"></asp:Label>
</ContentTemplate>
</atlas:UpdatePanel>
<atlas:UpdatePanel ID="UpdatePanel2" runat="server" Mode="Always">
<ContentTemplate>
<asp:Label ID="Label3" runat="server" Text="我是A!"></asp:Label>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="Button1" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
</td>
</tr>
<tr bgcolor=e6e6e6>
<td style="width: 101px">
我怎么总刷:</td>
<td style="width: 73px">
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" Width="94px">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="给我使劲喊" /></td>
<td style="width: 100px">
您选中了:<br/><asp:Label ID="Label2" runat="server" Text="Label" ForeColor="Red"></asp:Label>
<br />
<asp:Label ID="Label4" runat="server" Text="我是B!"></asp:Label></td>
</tr>
</table>
<br />
</div>
</form>
</body>
</html>