SharePoint provides ability to remove ribbon elements using custom actions. This method was tested and I think it is more preferrable and much more flexible, than inserting your custom controls into your masterpage. At least, because custom actions approach is available for sandboxed solutions.
In your case, you probably should use following code to define such custom action:
<CustomAction
Id="RemoveEditItemButtonFromCalendar"
Location="CommandUI.Ribbon.DisplayForm"
RegistrationType="List"
RegistrationId="106"
>
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.EditItem" />
</CommandUIDefinitions>
</CommandUIExtension>
</CustomAction>
106
here is the ID of Events list template. If you have your custom list template or standard template other than Events, you should use it instead of 106
value.
If you want to attach your ribbon customizations to a single list, rather than to a list template, you can use SPList.UserCustomActions collection. In your feature receiver you should place following code:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
// considering your feature is web-scoped
var web = properties.Feature.Parent as SPWeb;
// fetch SPList object, it must have been created before using this code
var list = web.GetListFromUrl("path/to/list/AllItems.aspx");
// create new customAction
var customAction = list.UserCustomActions.Add();
// this is for cleanup purposes in FeatureDeactivating
customAction.Name = properties.Feature.DefinitionId.ToString("N") + "_ribbon";
// setting custom action location, and the CommandUIExtension element
customAction.Location = "CommandUI.Ribbon.DisplayForm";
customAction.CommandUIExtension = @"
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location=""Ribbon.ListForm.Display.Manage.EditItem"" />
</CommandUIDefinitions>
</CommandUIExtension>"
// saving the changes to database
customAction.Update();
list.Update();
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
// cleanup code
SPWeb web = properties.Feature.Parent as SPWeb;
var list = web.GetListFromUrl("path/to/list/AllItems.aspx");
bool collectionChanged = false;
for (int i = list.UserCustomActions.Count - 1; i >= 0; i--)
{
var customAction = list.UserCustomActions.ElementAt(i);
if (customAction.Name.StartsWith(properties.Feature.DefinitionId.ToString("N")))
{
customAction.Delete();
collectionChanged = true;
}
}
if (collectionChanged)
list.Update();
}