0
kicks
How to access Master page members(like properties) from child page.
To Access public members like Property of a Master Page in Child Page we need to specify @MasterType directive with virtualpath attribute pointing to MasterPage path. i.e Use the @MasterType directive to set the strong type for the master page, as accessed through the Master property.
MasterPage:
public string masterVariable = "interviews.dotnetthread.com".
....
Child Page:
<%@ Page Language="C#" MasterPageFile="~/master/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="menu_master_Default" Title="Untitled Page" %>
<%@ MasterType VirtualPath="~/master/MasterPage.master" %>
Then in Page_Load we can access as below
sting childVar = this.Master.masterVariable;