在SharePoint(Asp.Net)表单中启用自动完成的正确方法?

在SharePoint(Asp.Net)表单中启用自动完成的正确方法?,sharepoint,internet-explorer,caching,autocomplete,Sharepoint,Internet Explorer,Caching,Autocomplete,SharePoint(WSS3和WSS2)中存在一个问题,即项目注册和编辑表单在Internet Explorer中没有“自动完成”功能。 也就是说,如果在某些文本字段中经常需要相同的值,则必须手动键入。Internet Explorer不提供您以前输入的值的下拉列表。然而,在FireFox中,这一点是可行的 正如我从中发现的,这是因为Internet Explorer在具有“无缓存”或“过期”标题的页面中禁用自动完成。SharePoint确实会将不可缓存的页面发送到客户端。这个SO响应还表示应

SharePoint(WSS3和WSS2)中存在一个问题,即项目注册和编辑表单在Internet Explorer中没有“自动完成”功能。
也就是说,如果在某些文本字段中经常需要相同的值,则必须手动键入。Internet Explorer不提供您以前输入的值的下拉列表。然而,在FireFox中,这一点是可行的

正如我从中发现的,这是因为Internet Explorer在具有“无缓存”或“过期”标题的页面中禁用自动完成。SharePoint确实会将不可缓存的页面发送到客户端。这个SO响应还表示应该将
autocomplete=“on”
添加到
表单
标记中,它会覆盖缓存头

我在服务器上的“默认母版”页面中编辑了表单元素,使其始终包含
autocomplete=“on”
和-yes,autocomplete功能有效

但是,因为它将被下一个service pack或修补程序覆盖

所以,问题是-我有什么选择来正确地解决这种情况?我希望在整个服务器场中启用自动完成

然而,微软警告我们不要这样做 按原样编辑“default.master” 被下一个服务覆盖 打包或修补

复制并粘贴具有不同名称的新母版页,并将其用作默认母版页。使用SharePoint designer或以编程方式设置SPWeb.MasterUrl和/或SPWeb.CustomMasterPage

为此,我有两个特性

  • 一个用于在当前网站上设置自定义母版页
  • 另一个是激活所有网站上以前的功能+将功能装订到新创建的网站上
(MWSBalticovo用于会议工作区-它们有不同的母版页)

用于单个网站使用自定义母版页的Web范围功能。 我的自定义母版页打包了一个功能:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <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>
第二个站点范围的功能,以启用以前的功能 elements.xml(在新创建的网站上激活第一个功能,但在现有网站上不会激活):

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