I am not sure if this is the best way to do this or not... but I've had to something similar (hiding/displaying stuff). I created a UserControl and then included it in the masterpage.
1. Write the code behind your user control
namespace YourCompany.Namespace
{
public class HideSiteActionsClass : System.Web.UI.UserControl
{
protected override void OnLoad(EventArgs e)
{
// do work to hide site actions depending on page
}
}
}
2. Create your usercontrol ascx file
Contents of C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\YourUserControl.ascx
<%@ Control Language="C#" Inherits="YourCompany.Namespace.HideSiteActionsClass,YourDLLThatHasTheClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4145551be317a94" compilationMode="Always" %>
3. Add your usercontrol to the masterpage
Put this at the top:
<%@ Register TagPrefix="yourTagPrefix" TagName="YourTagName" src="~/_controltemplates/YourUserControl.ascx" %>
Put this somewhere on the page:
<yourTagPrefix:YourTagName id="AUserControlID" runat="server" EnableViewState="false"></yourTagPrefix:YourTagName>
You can find info on google or this page.