How to Set Master Page Content to Child Page

First Add some controls in Master Page to read from Child Page

  1. <div class="main">  
  2.       <asp:Label ID="lblMaster" runat="server" Text="Master Label"></asp:Label>  
  3.       <asp:TextBox ID="txtMaster" runat="server"  placeholder="Master Textbox" ></asp:TextBox>  
  4.       <asp:ContentPlaceHolder ID="MainContent" runat="server" />  
  5. </div>  

Add Some controls in Child Page

  1. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">  
  2.   <br />  
  3.   <hr />  
  4.   <asp:Button ID="btnGetMasterPageContent" runat="server" Text="Get Master Page Content" OnClick="btnGetMasterPageContent_Click" />  
  5.   <asp:Button ID="btnSetMasterPageContent" runat="server" Text="Set Master Page Content" OnClick="btnSetMasterPageContent_Click" />  
  6.   <br /><br />  
  7.   <asp:Label ID="lblChild" runat="server" Text="Child Label"></asp:Label>  
  8.   <asp:TextBox ID="txtChild" placeholder="Child Textbox" runat="server"></asp:TextBox>  
  9. </asp:Content>  
Now Child Page Code behind
  1. protected void btnGetMasterPageContent_Click(object sender, EventArgs e)  
  2. {  
  3.   Label lblMaster = (Label)Master.FindControl("lblMaster");  
  4.   TextBox txtMaster = (TextBox)Master.FindControl("txtMaster");  
  5.   
  6.   if (lblMaster != null)  
  7.   {  
  8.     lblChild.Text = lblMaster.Text;  
  9.   }  
  10.   if (txtMaster != null)  
  11.   {  
  12.     txtChild.Text = txtMaster.Text;  
  13.   }  
  14. }  
  15. protected void btnSetMasterPageContent_Click(object sender, EventArgs e)  
  16. {  
  17.   Label lblMaster = (Label)Master.FindControl("lblMaster");  
  18.   TextBox txtMaster = (TextBox)Master.FindControl("txtMaster");  
  19.   
  20.   if (lblMaster != null)  
  21.     lblMaster.Text = lblChild.Text;  
  22.   if (txtMaster != null)  
  23.     txtMaster.Text = txtChild.Text;  
  24. }  

Note: Hope now you can Access Master Page Contents as well as can set also data from child page.