referrence master page

S

simonZ

Since i have to handling the event from master page in every content page, I
created custom page class,
which handles the master page event:

public class myPage: System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
Master.masterClick += new masterEventsEventHandler(this.getTitles);
base.OnInit(e);
}

protected virtual void getTitles (object sender, masterEventsEventArg e)
{

}
}

I get the following error:

Error 1 'System.Web.UI.MasterPage' does not contain a definition for
'masterClick'

How can I rference my master page from page base class file?
In class, I can't put MasterType page directive.

regards,Simon
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

The generic Master Page object does not have your custom masterClick event,
and that is what you are referencing.
You need to cast it to your specific master page.
So code something like this should do the trick:

MyMasterPageClass MyMaster = (MyMasterPageClass)Master;
MyMaster.masterClick += new masterEventsEventHandler(this.getTitles);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top