G
Guest
Hi folks!
I have a MasterPage with some public methods, and I would like to call them
from a (app_code) class. Is it possible to set a directive or an assembly
reference to a MasterPage from a normal class?
I have no problem to call the masterpage's methods from a contentpage, but
what I would like to do is someting like this...
public partial class MyMaster : System.Web.UI.MasterPage
{
public void MyMethod()
{
// Do some nice stuff...
}
}
public partial class MyContentPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MyMaster master = (MyMaster)this.Master;
master.MyMethod(); // Works fine!
MyStaticClass.MyStaticMethod(this.Page); // This is what I would
like to do...
}
}
public static class MyStaticClass
{
public static void MyStaticMethod(Page page, bool SomeKindOfParamter)
{
// Here I would like to call the MyMaster.MyMethod() but I don't now
how???
(
// There is no problem to get a reference to the calling page's MasterPage
like this...
MasterPage master = page.Master; // Works fine, but it's ofcause useless
because MyMethod is not availible.
// This is what I would like to do...
/*
MyMaster master = (MyMaster)page.Master;
if (SomeKindOfParamter == true) // Just an example
)
{
master.MyMethod(); // Is it possible to reach in some way???
// I don't now how to set a directive or an assembly reference to
MyMaster
}
*/
}
Thanks in advance!
//Leffe
I have a MasterPage with some public methods, and I would like to call them
from a (app_code) class. Is it possible to set a directive or an assembly
reference to a MasterPage from a normal class?
I have no problem to call the masterpage's methods from a contentpage, but
what I would like to do is someting like this...
public partial class MyMaster : System.Web.UI.MasterPage
{
public void MyMethod()
{
// Do some nice stuff...
}
}
public partial class MyContentPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MyMaster master = (MyMaster)this.Master;
master.MyMethod(); // Works fine!
MyStaticClass.MyStaticMethod(this.Page); // This is what I would
like to do...
}
}
public static class MyStaticClass
{
public static void MyStaticMethod(Page page, bool SomeKindOfParamter)
{
// Here I would like to call the MyMaster.MyMethod() but I don't now
how???
// There is no problem to get a reference to the calling page's MasterPage
like this...
MasterPage master = page.Master; // Works fine, but it's ofcause useless
because MyMethod is not availible.
// This is what I would like to do...
/*
MyMaster master = (MyMaster)page.Master;
if (SomeKindOfParamter == true) // Just an example
{
master.MyMethod(); // Is it possible to reach in some way???
// I don't now how to set a directive or an assembly reference to
MyMaster
}
*/
}
Thanks in advance!
//Leffe