<%@ MasterType VirtualPath="~/MasterPage.master" %>
VirtualPath 指向 MasterPage 的相對路徑。
public void SetValue(string s)
{
this.Label1.Text = s;
}
public string GetValue()
{
return this.Label1.Text;
}
// 寫入資料
Master.SetValue("來自內容頁的訊息");
// 讀取資料
string msg = Master.GetValue();
透過 Master 屬性即可存取 MasterPage 公開的方法,實現強型別的跨頁資料交換。