2010-03-11 41 views
0

SharePoint(WSS3和WSS2)存在一個問題,即項目註冊和編輯表單在Internet Explorer中沒有「自動完成」功能。
也就是說,如果您經常在某些文本字段中需要相同的值,則必須手動輸入。 Internet Explorer不會爲您提供先前輸入的值的下拉列表。然而,在FireFox中這個東西很有用。在SharePoint(Asp.Net)窗體中啓用自動完成功能的正確方法?

當我從this response to a similar question發現,這是因爲Internet Explorer中有「無緩存」或「過期」頭頁面禁用自動完成。 SharePoint確實會向客戶端發送不可緩存的頁面。該SO響應還表示,應該將autocomplete="on"添加到form標記,它會覆蓋緩存標頭。

我在我的服務器上的「默認主頁」頁面中編輯了FORM元素,始終包含autocomplete="on"和 - 是的,自動完成功能的作品!

但是,Microsoft warns us NOT to edit the "default.master"因爲它將被下一個Service Pack或補丁覆蓋。

所以,問題是 - 我的選項正確解決這種情況?我希望在整個服務器場中啓用自動完成功能。

回答

2

但是,微軟警告我們不要 編輯「default.master」,因爲它會通過 下一個服務包 或補丁覆蓋。

複製&粘貼具有不同名稱的新主頁並將其用作默認頁面。使用SharePoint設計器或以編程方式設置SPWeb.MasterUrl和/或SPWeb.CustomMasterPage。

對於這一點,我有2個特點

  • 一到當前網站上設置自定義母版頁
  • 其他一個對所有網+主食功能激活之前的功能,新創建的網站的

Project http://img251.imageshack.us/img251/7351/ss20100312093605.png (MWSBalticovo是爲了滿足工作空間 - 他們有不同的母版)

國營石油網使用自定義母版頁的單個網站的編輯功能。

我有我的自定義主頁功能打包:

<?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> 

而且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(); 
} 

第二站點範圍的功能,使以前的所有功能

元素。XML(激活第一個功能上的新創建的網站的,但在現有的將不激活):

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

FeatureReceiver(激活現有的網1功能):

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(); 
     } 
    } 
}