Base Class which will have the common Functions, I have jst defined only a click event and a GetStr Method.
public class ProductBase : System.Web.UI.MasterPage
{
public string GetStr()
{
return "hello";
}
protected virtual void Button1_Click(object sender, EventArgs e)
{
Response.Write("<BR>Master Btn Clicked<BR>");
}
}
The Master Page in the root will have a Button and i have the Click event for it define in the ProductBase.
public
partial class MasterPage : ProductBase
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("<BR> From Master Page <BR>");
}
public string GetVal()
{
return "Hello from root Master";
}
}
AuthMasterPage
<%@ Master MasterPageFile="~/MasterPage.master" Language="C#" AutoEventWireup="true" CodeFile="AuthMasterPage.master.cs" Inherits="AuthMasterPage" %>
<asp:content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
</asp:content>
public
partial class AuthMasterPage : ProductBase
{
public MasterPage rootMaster;
protected void Page_Load(object sender, EventArgs e)
{
rootMaster = (MasterPage)this.Master;
rootMaster.GetVal();
}
public string GetAuthVal()
{
return rootMaster.GetVal();// "Hello From Auth";
}
}
Content Page in Auth folder....
<%@ Page Language="C#" MasterPageFile="~/Authentication/AuthMasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
public
partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MasterPage mp = (MasterPage)this.Master;
//mp.ge
}
}
Let me know if anything in not clear or i have missed.
Thanks
Mohan