標記:爲什麼在Page_Load事件處理程序中沒有設置Label控件的文本屬性?
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Files.aspx.cs" Inherits="WebModules.Web.Files" %>
<!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">
</head>
<body>
<form id="form1" method="post" runat="server">
<asp:Label ID="Status" runat="server" />
</form>
</body>
</html>
代碼背後:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
namespace WebModules.Web
{
public partial class Files : System.Web.UI.Page
{
private void Page_Load(object sender, EventArgs e)
{
Status.Text="Hello";
}
private void Page_Init(object sender, EventArgs e)
{
InitializeComponent();
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
}
}
當我在瀏覽器中運行網頁中的文字 「你好」 是不是在標籤上顯示。
有誰知道爲什麼這不起作用?
這對我來說工作得很好。 – JonH 2012-08-07 17:42:55
你爲什麼改變頁面初始化週期? – 2012-08-07 17:43:03
@AndreCalil請回答點 – 2012-08-07 17:44:22