编程实现>ASP.NET 3.5开发范例精讲精析>探讨基础的ASP.NET服务器控件>Label服务器控件
描述:需要在服务器端程序代码中更改静态文本的内容或其他属性,使用Label控件。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CH5_DemoForm001.aspx.cs" Inherits="CH5.CH5_DemoForm001" %>
<!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 id="Head1" runat="server">
<title>Label 服务器控件使用示范</title>
</head>
<body>
<form id="form1" runat="server" defaultbutton="btnOk" defaultfocus="TextBox1">
<a target="_blank" href="http://www.cnblogs.com/liminzhang">
<img style="border: 0" alt="" src="Images/CH5_DemoForm001_Banner.jpg" title="前往新势讯科技之章立民研究室" /></a>
<div>
请输入姓名:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnOk" runat="server" Text="确定" Font-Size="11pt"
onclick="btnOk_Click"></asp:Button>
<hr />
<asp:Label ID="lblMessage" runat="server" ForeColor="#C00000"></asp:Label>
</div>
</form>
</body>
</html>
<!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 id="Head1" runat="server">
<title>Label 服务器控件使用示范</title>
</head>
<body>
<form id="form1" runat="server" defaultbutton="btnOk" defaultfocus="TextBox1">
<a target="_blank" href="http://www.cnblogs.com/liminzhang">
<img style="border: 0" alt="" src="Images/CH5_DemoForm001_Banner.jpg" title="前往新势讯科技之章立民研究室" /></a>
<div>
请输入姓名:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnOk" runat="server" Text="确定" Font-Size="11pt"
onclick="btnOk_Click"></asp:Button>
<hr />
<asp:Label ID="lblMessage" runat="server" ForeColor="#C00000"></asp:Label>
</div>
</form>
</body>
</html>