Ian Andersen
Ian Andersen

Reputation:

How do you set the MasterType TypeName in code

If you want easy access to the MasterPage properties etc in ASP.Net you can set the MasterPage TypeName in the head of the aspx page i.e.

But How do you do this via the code file?

Upvotes: 1

Views: 2217

Answers (2)

Stewart
Stewart

Reputation: 51

protected void Page_PreInit(object sender, EventArgs e) 
{
    this.MasterPageFile = "~/Site.master"; 
}

From: Specifying the Master Page Programmatically (C#)

Upvotes: 1

Rony
Rony

Reputation: 9511

TypeName is the Base class from which your Master page is going to derive so if you have defined your own BaseMaster Pag, in the code behind of the Master page inherit from your CustomMaster

instead of System.Web.UI.MasterPage inherit from CustomMaster

Upvotes: 1

Related Questions