"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
>
Well, what *do* you know about the type? It looks like you know it will
have a Master property of a particular type. So encapsulate that in an
interface, make all the relevant pages implement that interface, and
cast to that interface.
Well, I implemented the interface in the master page so that other pages can
implement this interface. I have to say I'm not that experienced with
interfaces and what I read isn't shedding any light on this for me.
Master Page :
interface ISearchMake
{
string GetSearchMake();
}
public partial class Main : System.Web.UI.MasterPage
{
string _SearchMake = "";
public string GetSearchMake
{
get {return _SearchMake;}
}
Single Page :
public partial class Search : System.Web.UI.Page, ISearchMake
{
protected void Page_Load(object sender, EventArgs e)
{
// Do stuff
}
}
My Control (can appear on any page) :
public partial class Search : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CF.ISearchMake MySource;
MySource = (CF.ISearchMake)Context.Handler;
Literal1.Text = MySource.GetSearchMake();
}
}
}
Gives me an error :
Error 1 'CF.Search' does not implement interface member
CF.ISearchMake.GetSearchMake()