Hi,
You can try to expose the variable in the user control, then it can be accessed.
Below is me sample code:
1. the user control, expose the variable in the codebheind:
private string _lbl;
public string lbl
{
get
{
return _lbl;
}
set
{
_lbl = value;
}
}
2. Then expose this user control in the master page's codebehind:
public ASP.testusercontrol_usercontrols_uc1l_ascx control
{
get
{
return this.UC1l1;
}
}
UC1l1 is the usercontrol's ID in the master page, ASP.testusercontrol_usercontrols_uc1l_ascx is the type of my usercontrol.
3. add the @materType directive for the content page:
<%@ Page Language="C#" MasterPageFile="~/TestUserControl/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="TestUserControl_Default" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/TestUserControl/MasterPage.master" %>
4. Access the usercontrol's variable in the content page's codebehind:
ASP.testusercontrol_usercontrols_uc1l_ascx usercontrol = this.Master.control;
usercontrol.lbl = "this is the content page's message!";
Hope it helps.