나는 당신이 맞다면,이 예제를 사용,의 MasterPage에서 변수에 액세스하려는 페이지를 주장이라고 할 예정 콘텐츠 페이지의 시작 부분에 다음 지시문을 설정
<%@ MasterType virtualPath="~/MasterPage.Master"%>
은 다음 Master.NameVariable를 사용하여 MasterPage의 공용 변수를 사용할 수 있습니다. 다른 경우
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox1.Text = Master.strEmpresa;
}
}
당신이 정말로 MasterPage에서 ContentPage의 변수에 액세스하려는 경우, 당신은 단지 MasterPage로 읽을 세션의 값을 설정할 수 있습니다. 예 :
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["myVariable"] != null)
{
TextBox1.Text = Session["myVariable"].ToString();
}
}
}
}
public partial class WebFormMP_TestPublicVariable : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["myVariable"] = "Test";
}
}
}
이 방법은 여러 가지가 있습니다. 인터넷 주위를 확인;).
이것은 그리 어렵지 않습니다. Google 검색을 해 보셨나요 ..? 거기에 많은 예제가 여기에 예제 중 하나입니다 여기에 http://stackoverflow.com/questions/3651326/asp-net-access-a-master-page-variable-through-content-page – MethodMan