views:

466

answers:

1

There is a problem in SharePoint (both WSS3 and WSS2) that item registration and edit forms do not have the "autocomplete" feature in Internet Explorer.
That is, if you need the same value in some text field frequently, you have to type it manually. Internet Explorer does not provide you with drop-down list of values you have previously entered. In FireFox this thing works, however.

As I found out from this response to a similar question, it is because Internet Explorer disables auto-complete in pages which have "no-cache" or "expires" headers. SharePoint really does send non-cacheable pages to the client. This SO response also says that one should add autocomplete="on" to the form tag, it overrides the cache headers.

I edited the FORM element in "default master" page on my server to always include the autocomplete="on" and - yes, autocomplete feature works!

However, Microsoft warns us NOT to edit the "default.master" as it will be overwritten by the next service pack or patch.

So, the question is - what are my options to correctly solve this situation? I want to have autocomplete to be enabled in whole server farm.

+1  A: 

However, Microsoft warns us NOT to edit the "default.master" as it will be overwritten by the next service pack or patch.

Copy & Paste new masterpage with different name and use it as the default one. Use either SharePoint designer or programmatically set SPWeb.MasterUrl and/or SPWeb.CustomMasterPage.

For this, i have 2 features

  • One to set custom master page on current website
  • Other one to activate previous feature on all webs + staple feature to newly created web's

Project (MWSBalticovo is for meeting workspace - they have a different masterpage)

Web scoped feature for a single web site to use custom masterpage.

I have a feature with my custom master page packaged:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <Module Name="BalticovoMasterPages" List="116" Url="_catalogs/masterpage" RootWebOnly="TRUE" Path="MasterPages">
        <File Url="Balticovo.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
            <Property Name="ContentType"            Value="$Resources:core,MasterPage;"/>
            <Property Name="MasterPageDescription"  Value="$Resources:Balticovo,BalticovoMasterPageDescription;"/>
        </File>
        <File Url="MWSBalticovo.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
            <Property Name="ContentType"            Value="$Resources:core,MasterPage;"/>
            <Property Name="MasterPageDescription"  Value="$Resources:Balticovo,MWSBalticovoMasterPageDescription;"/>
        </File>
    </Module>
</Elements>

And FeatureReceiver:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    SPWeb web = properties.Feature.Parent as SPWeb;

    string masterUrl = "/_catalogs/masterpage/Balticovo.master";
    string mwsMasterUrl = "/_catalogs/masterpage/MWSBalticovo.master";

    if (web.CustomMasterUrl.ToLower().Contains("/mws")) //meeting workspace
        web.CustomMasterUrl = mwsMasterUrl;
    else
        web.CustomMasterUrl = masterUrl;

    web.MasterUrl = masterUrl;
    web.Update();
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
    SPWeb web = properties.Feature.Parent as SPWeb;
    web.MasterUrl = "/_catalogs/masterpage/default.master";
    if (web.CustomMasterUrl.ToLower().Contains("/mws")) //meetng workspace
        web.CustomMasterUrl = "/_catalogs/masterpage/MWSdefault.master";
    else
        web.CustomMasterUrl = "/_catalogs/masterpage/default.master";
    web.Update();
}

2nd Site scoped feature to enable previous features

elements.xml (activate 1st feature on newly created web's, but will not activate on existing):

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <FeatureSiteTemplateAssociation
        TemplateName="GLOBAL"
        Id="{227c6aed-f66b-482d-aea8-a2af3ca203b7}" />
</Elements>

FeatureReceiver (activate 1st feature on existing webs):

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
    Guid masterPageFeatureId = new Guid("{227c6aed-f66b-482d-aea8-a2af3ca203b7}");
    SPSite site = properties.Feature.Parent as SPSite;
    SPWebCollection webs = site.AllWebs;
    foreach (SPWeb web in webs)
    {
        try
        {
            if (web.Features[masterPageFeatureId] == null)
                web.Features.Add(masterPageFeatureId);
        }
        catch (InvalidOperationException)  //target feature not yet installed
        { throw; }
        catch (SPException) { } //If feature could not be activated.
        finally
        {
            if (web != null)
                web.Dispose();
        }
    }
}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
    Guid masterPageFeatureId = new Guid("{227c6aed-f66b-482d-aea8-a2af3ca203b7}");
    SPSite site = properties.Feature.Parent as SPSite;
    SPWebCollection webs = site.AllWebs;
    foreach (SPWeb web in webs)
    {
        try
        {
            if (web.Features[masterPageFeatureId] == null)
                web.Features.Remove(masterPageFeatureId);
        }
        catch (InvalidOperationException) { }
        catch (SPException) { }
        finally
        {
            if (web != null)
                web.Dispose();
        }
    }
}
Janis Veinbergs