<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: MasterPages hate logic. Throw Interfaces at Them.</title>
	<atom:link href="http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<pubDate>Thu, 04 Dec 2008 03:02:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: seth</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-665233</link>
		<dc:creator>seth</dc:creator>
		<pubDate>Fri, 28 Mar 2008 18:44:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-665233</guid>
		<description>(sorry the code in my first post wasn't formatted properly)

I agree that interfaces are good, but that solution seems overly complicated to me.

The base page does not need to be involved at all and the button.click event handlers should be in the code behind for the master page.

If I were going to use interfaces to solve the example here's what I would do:

&lt;b&gt;Interface Definition&lt;/b&gt;


Public Interface IAddable
&#160;&#160;&#160; Sub Add()
End Interface
&#160;
Public Interface IEditable
&#160;&#160;&#160; Sub Edit()
End Interface
&#160;
Public Interface IDeletable
&#160;&#160;&#160; Sub Delete()
End Interface
&#160;
Public Interface IExitable
&#160;&#160;&#160; Sub [Exit]()
End Interface
&#160;
Public Interface ICommandButtonContainer
&#160;&#160;&#160; ReadOnly Property AddButton() As Button
&#160;&#160;&#160; ReadOnly Property EditButton() As Button
&#160;&#160;&#160; ReadOnly Property DeleteButton() As Button
&#160;&#160;&#160; ReadOnly Property ExitButton() As Button
End Interface



&lt;b&gt;Code Behind for Master Page&lt;/b&gt;


Partial Class MasterPage
&#160;&#160;&#160; Inherits System.Web.UI.MasterPage
&#160;&#160;&#160; Implements ICommandButtonContainer
&#160;
&#160;&#160;&#160; Public ReadOnly Property AddButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.AddButton
&#160;&#160;&#160; &#160;&#160;&#160; Get
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; 'return a reference to the button
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; Return btnAdd
&#160;&#160;&#160; &#160;&#160;&#160; End Get
&#160;&#160;&#160; End Property
&#160;
&#160;&#160;&#160; Public ReadOnly Property DeleteButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.DeleteButton
&#160;&#160;&#160; &#160;&#160;&#160; Get
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; Return btnDelete
&#160;&#160;&#160; &#160;&#160;&#160; End Get
&#160;&#160;&#160; End Property
&#160;
&#160;&#160;&#160; Public ReadOnly Property EditButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.EditButton
&#160;&#160;&#160; &#160;&#160;&#160; Get
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; Return btnEdit
&#160;&#160;&#160; &#160;&#160;&#160; End Get
&#160;&#160;&#160; End Property
&#160;
&#160;&#160;&#160; Public ReadOnly Property ExitButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.ExitButton
&#160;&#160;&#160; &#160;&#160;&#160; Get
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; Return btnExit
&#160;&#160;&#160; &#160;&#160;&#160; End Get
&#160;&#160;&#160; End Property
&#160;
&#160;&#160;&#160; Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
&#160;&#160;&#160; &#160;&#160;&#160; 'if the child page implements IAddable then call it's Add() method
&#160;&#160;&#160; &#160;&#160;&#160; If TypeOf Page Is IAddable Then
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; CType(Page, IAddable).Add()
&#160;&#160;&#160; &#160;&#160;&#160; End If
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Protected Sub btnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click
&#160;&#160;&#160; &#160;&#160;&#160; If TypeOf Page Is IEditable Then
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; CType(Page, IEditable).Edit()
&#160;&#160;&#160; &#160;&#160;&#160; End If
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
&#160;&#160;&#160; &#160;&#160;&#160; If TypeOf Page Is IDeletable Then
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; CType(Page, IDeletable).Delete()
&#160;&#160;&#160; &#160;&#160;&#160; End If
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Protected Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
&#160;&#160;&#160; &#160;&#160;&#160; If TypeOf Page Is IExitable Then
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; CType(Page, IExitable).Exit()
&#160;&#160;&#160; &#160;&#160;&#160; End If
&#160;&#160;&#160; End Sub
End Class



&lt;b&gt;Code behind for Page&lt;/b&gt;


Partial Class _Default
&#160;&#160;&#160; Inherits Web.UI.Page
&#160;&#160;&#160; Implements IAddable, IDeletable, IEditable, IExitable
&#160;
&#160;&#160;&#160; Public Sub Add() Implements IAddable.Add
&#160;&#160;&#160; &#160;&#160;&#160; WhatWasClicked.Text = "Add"
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Public Sub Delete() Implements IDeletable.Delete
&#160;&#160;&#160; &#160;&#160;&#160; WhatWasClicked.Text = "Delete"
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Public Sub Edit() Implements IEditable.Edit
&#160;&#160;&#160; &#160;&#160;&#160; WhatWasClicked.Text = "Edit"
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Public Sub [Exit]() Implements IExitable.Exit
&#160;&#160;&#160; &#160;&#160;&#160; WhatWasClicked.Text = "Exit"
&#160;&#160;&#160; End Sub
&#160;
&#160;&#160;&#160; Protected Sub btnApplyChanges_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApplyChanges.Click
&#160;&#160;&#160; &#160;&#160;&#160; If TypeOf Master Is ICommandButtonContainer Then
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; Dim container As ICommandButtonContainer = Master
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; container.AddButton.Enabled = AddableCheckbox.Checked
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; container.DeleteButton.Enabled = DeletableCheckbox.Checked
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; container.EditButton.Enabled = EditableCheckbox.Checked
&#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; container.ExitButton.Enabled = ExitableCheckbox.Checked
&#160;&#160;&#160; &#160;&#160;&#160; End If
&#160;&#160;&#160; End Sub
End Class
</description>
		<content:encoded><![CDATA[<p>(sorry the code in my first post wasn&#8217;t formatted properly)</p>
<p>I agree that interfaces are good, but that solution seems overly complicated to me.</p>
<p>The base page does not need to be involved at all and the button.click event handlers should be in the code behind for the master page.</p>
<p>If I were going to use interfaces to solve the example here&#8217;s what I would do:</p>
<p><b>Interface Definition</b></p>
<p>Public Interface IAddable<br />
&nbsp;&nbsp;&nbsp; Sub Add()<br />
End Interface<br />
&nbsp;<br />
Public Interface IEditable<br />
&nbsp;&nbsp;&nbsp; Sub Edit()<br />
End Interface<br />
&nbsp;<br />
Public Interface IDeletable<br />
&nbsp;&nbsp;&nbsp; Sub Delete()<br />
End Interface<br />
&nbsp;<br />
Public Interface IExitable<br />
&nbsp;&nbsp;&nbsp; Sub [Exit]()<br />
End Interface<br />
&nbsp;<br />
Public Interface ICommandButtonContainer<br />
&nbsp;&nbsp;&nbsp; ReadOnly Property AddButton() As Button<br />
&nbsp;&nbsp;&nbsp; ReadOnly Property EditButton() As Button<br />
&nbsp;&nbsp;&nbsp; ReadOnly Property DeleteButton() As Button<br />
&nbsp;&nbsp;&nbsp; ReadOnly Property ExitButton() As Button<br />
End Interface</p>
<p><b>Code Behind for Master Page</b></p>
<p>Partial Class MasterPage<br />
&nbsp;&nbsp;&nbsp; Inherits System.Web.UI.MasterPage<br />
&nbsp;&nbsp;&nbsp; Implements ICommandButtonContainer<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public ReadOnly Property AddButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.AddButton<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Get<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#8216;return a reference to the button<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Return btnAdd<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End Get<br />
&nbsp;&nbsp;&nbsp; End Property<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public ReadOnly Property DeleteButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.DeleteButton<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Get<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Return btnDelete<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End Get<br />
&nbsp;&nbsp;&nbsp; End Property<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public ReadOnly Property EditButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.EditButton<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Get<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Return btnEdit<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End Get<br />
&nbsp;&nbsp;&nbsp; End Property<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public ReadOnly Property ExitButton() As System.Web.UI.WebControls.Button Implements ICommandButtonContainer.ExitButton<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Get<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Return btnExit<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End Get<br />
&nbsp;&nbsp;&nbsp; End Property<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &#8216;if the child page implements IAddable then call it&#8217;s Add() method<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If TypeOf Page Is IAddable Then<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CType(Page, IAddable).Add()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Protected Sub btnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEdit.Click<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If TypeOf Page Is IEditable Then<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CType(Page, IEditable).Edit()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If TypeOf Page Is IDeletable Then<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CType(Page, IDeletable).Delete()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Protected Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If TypeOf Page Is IExitable Then<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CType(Page, IExitable).Exit()<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
End Class</p>
<p><b>Code behind for Page</b></p>
<p>Partial Class _Default<br />
&nbsp;&nbsp;&nbsp; Inherits Web.UI.Page<br />
&nbsp;&nbsp;&nbsp; Implements IAddable, IDeletable, IEditable, IExitable<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public Sub Add() Implements IAddable.Add<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WhatWasClicked.Text = &#8220;Add&#8221;<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public Sub Delete() Implements IDeletable.Delete<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WhatWasClicked.Text = &#8220;Delete&#8221;<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public Sub Edit() Implements IEditable.Edit<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WhatWasClicked.Text = &#8220;Edit&#8221;<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Public Sub [Exit]() Implements IExitable.Exit<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WhatWasClicked.Text = &#8220;Exit&#8221;<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp; Protected Sub btnApplyChanges_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApplyChanges.Click<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; If TypeOf Master Is ICommandButtonContainer Then<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Dim container As ICommandButtonContainer = Master<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; container.AddButton.Enabled = AddableCheckbox.Checked<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; container.DeleteButton.Enabled = DeletableCheckbox.Checked<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; container.EditButton.Enabled = EditableCheckbox.Checked<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; container.ExitButton.Enabled = ExitableCheckbox.Checked<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; End If<br />
&nbsp;&nbsp;&nbsp; End Sub<br />
End Class</p>]]></content:encoded>
	</item>
	<item>
		<title>By: pandojc</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-119212</link>
		<dc:creator>pandojc</dc:creator>
		<pubDate>Thu, 07 Dec 2006 18:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-119212</guid>
		<description>Thanks for the post. I was struggling with how to reconcile master pages with a custom page base... this was the answer I was looking for!</description>
		<content:encoded><![CDATA[<p>Thanks for the post. I was struggling with how to reconcile master pages with a custom page base&#8230; this was the answer I was looking for!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: wwb_99</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-72544</link>
		<dc:creator>wwb_99</dc:creator>
		<pubDate>Mon, 23 Oct 2006 12:00:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-72544</guid>
		<description>Sounds like it converted into a web application project. Which is no matter; just put the stuff from app_code in a separate class library and reference it.

Note the library will need to reference System.Web.</description>
		<content:encoded><![CDATA[<p>Sounds like it converted into a web application project. Which is no matter; just put the stuff from app_code in a separate class library and reference it.</p>
<p>Note the library will need to reference System.Web.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: tomandlis</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-72540</link>
		<dc:creator>tomandlis</dc:creator>
		<pubDate>Mon, 23 Oct 2006 11:49:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-72540</guid>
		<description>I should add that I migrated this from a vs 2003 web app.  I suppose that has something to do with the missing option for app_code</description>
		<content:encoded><![CDATA[<p>I should add that I migrated this from a vs 2003 web app.  I suppose that has something to do with the missing option for app_code</p>]]></content:encoded>
	</item>
	<item>
		<title>By: tomandlis</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-72534</link>
		<dc:creator>tomandlis</dc:creator>
		<pubDate>Mon, 23 Oct 2006 11:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-72534</guid>
		<description>When I right click my web project I don't have the option to add an App_code folder.  Its missing and I can't add it :-(

All I can see is 

App_globalresources
App_localresources
App_data
App_browsers
Theme

Argh, I think your code sample above will work for me, but I'm stuck on step 1.</description>
		<content:encoded><![CDATA[<p>When I right click my web project I don&#8217;t have the option to add an App_code folder.  Its missing and I can&#8217;t add it :-(</p>
<p>All I can see is </p>
<p>App_globalresources<br />
App_localresources<br />
App_data<br />
App_browsers<br />
Theme</p>
<p>Argh, I think your code sample above will work for me, but I&#8217;m stuck on step 1.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: wwb_99</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-63299</link>
		<dc:creator>wwb_99</dc:creator>
		<pubDate>Tue, 03 Oct 2006 13:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-63299</guid>
		<description>Glad you found it useful Rui. I actually came up with this pattern while trying to solve a similar problem. Now, there is probably an official name, but official design patterns never were my thing.</description>
		<content:encoded><![CDATA[<p>Glad you found it useful Rui. I actually came up with this pattern while trying to solve a similar problem. Now, there is probably an official name, but official design patterns never were my thing.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Rui da Luz</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-63235</link>
		<dc:creator>Rui da Luz</dc:creator>
		<pubDate>Tue, 03 Oct 2006 11:14:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-63235</guid>
		<description>I was trying to solve the problem of having a page that "implements" a master page and, in the other hand, inherits from a custom base page class. The dificulty was that we can't access properties in the master page through the custom base page class. Well, your article really opened may mind. Using an interface to perform this access to the master page works fine.

To do this i create a master base page that implements ITeste named BaseMaster (in VB) and i made the property implemented from the interface MustOverride:

Public MustInherit Class BaseMaster

    Inherits MasterPage

    Implements ITeste

#Region "ITeste Implementation"

    MustOverride Property MenuHiddenz() As Boolean Implements ITeste.MenuHiddenz

#End Region

Public Interface ITeste

    Property MenuHiddenz() As Boolean

End Interface


Then in the page that "implements" BaseMaster:

Public Overrides Property MenuHiddenz() As Boolean
    Get
        Return Not Me.MainMenu.Visible
    End Get
    Set(ByVal value As Boolean)
        Me.MainMenu.Visible = Not value
    End Set
End Property


Finally, in the custom base page class i can access the master page:

DirectCast(Me.Master, ITeste).MenuHiddenz = True 

or in C#

(ITeste)this.Master.MenuHiddenz = true;


Thank's a lot Wyatt</description>
		<content:encoded><![CDATA[<p>I was trying to solve the problem of having a page that &#8220;implements&#8221; a master page and, in the other hand, inherits from a custom base page class. The dificulty was that we can&#8217;t access properties in the master page through the custom base page class. Well, your article really opened may mind. Using an interface to perform this access to the master page works fine.</p>
<p>To do this i create a master base page that implements ITeste named BaseMaster (in VB) and i made the property implemented from the interface MustOverride:</p>
<p>Public MustInherit Class BaseMaster</p>
<p>    Inherits MasterPage</p>
<p>    Implements ITeste</p>
<p>#Region &#8220;ITeste Implementation&#8221;</p>
<p>    MustOverride Property MenuHiddenz() As Boolean Implements ITeste.MenuHiddenz</p>
<p>#End Region</p>
<p>Public Interface ITeste</p>
<p>    Property MenuHiddenz() As Boolean</p>
<p>End Interface</p>
<p>Then in the page that &#8220;implements&#8221; BaseMaster:</p>
<p>Public Overrides Property MenuHiddenz() As Boolean<br />
    Get<br />
        Return Not Me.MainMenu.Visible<br />
    End Get<br />
    Set(ByVal value As Boolean)<br />
        Me.MainMenu.Visible = Not value<br />
    End Set<br />
End Property</p>
<p>Finally, in the custom base page class i can access the master page:</p>
<p>DirectCast(Me.Master, ITeste).MenuHiddenz = True </p>
<p>or in C#</p>
<p>(ITeste)this.Master.MenuHiddenz = true;</p>
<p>Thank&#8217;s a lot Wyatt</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-62013</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Sat, 30 Sep 2006 23:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-62013</guid>
		<description>Excellent! Great explanation and the code works perfectly.</description>
		<content:encoded><![CDATA[<p>Excellent! Great explanation and the code works perfectly.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Hima_.net</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-51845</link>
		<dc:creator>Hima_.net</dc:creator>
		<pubDate>Tue, 05 Sep 2006 10:57:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-51845</guid>
		<description>Good article .
You have been kicked</description>
		<content:encoded><![CDATA[<p>Good article .<br />
You have been kicked</p>]]></content:encoded>
	</item>
	<item>
		<title>By: ses5909</title>
		<link>http://www.sitepoint.com/blogs/2006/08/31/masterpages-hate-logic-throw-interfaces-at-them/#comment-49389</link>
		<dc:creator>ses5909</dc:creator>
		<pubDate>Thu, 31 Aug 2006 06:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1700#comment-49389</guid>
		<description>This is an excellent post. You broke it down very well. Thanks.</description>
		<content:encoded><![CDATA[<p>This is an excellent post. You broke it down very well. Thanks.</p>]]></content:encoded>
	</item>
</channel>
</rss>
