Literal跟PlaceHolder都是可以用來動態載入網頁內容用的控制項
差別在Literal是直接寫入html內容
PlaceHolder是加入另一個Controls
假設在網頁上有Literal與PlaceHolder
以下的程式碼就可以看出功能上的差異
protected void Button1_Click(object sender, EventArgs e)
{
Label lable = new Label();
lable.Text = "This new Label1.";
label.Bold = true;
this.PlaceHolder1.Controls.Add(label);
this.Literal1.Text = "<b>This new Label2.</b>";
}
转自:http://www.purecs.net/thread/topic389_1.aspx
我想其實Literal跟PlaceHolder是可以只寫成一個控制項並提供兩者的功能才對
不過微軟並沒有這麼做