The below example only sets the Master page URL, but not the custom master page URL. thus Layout pages will be the same after you deploy the master page. You can also change the Custom master page URL.
Feature Activation
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
string urlMaster;
string urlCustom;
if (@"/".Equals(web.ServerRelativeUrl))
{
urlMaster = @"/_catalogs/masterpage/BLLICT.master";
urlCustom = @"/_catalogs/masterpage/v4.master";
}
else {
urlMaster = string.Concat(web.ServerRelativeUrl ,
@"/_catalogs/masterpage/BLLICT.master");
urlCustom = string.Concat(web.ServerRelativeUrl ,
@"/_catalogs/masterpage/v4.master");
}
web.MasterUrl = urlMaster;
web.CustomMasterUrl = urlCustom;
web.Update();
}
Feature Deactivation (Reverse to Original Master)
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
string urlCustom;
if (@"/".Equals(web.ServerRelativeUrl))
{
urlCustom = @"/_catalogs/masterpage/v4.master";
}
else
{
urlCustom = string.Concat(web.ServerRelativeUrl,
@"/_catalogs/masterpage/v4.master");
}
web.MasterUrl = urlCustom;
web.CustomMasterUrl = urlCustom;
web.Update();
}