Domanda

Qui è il problema: usando SPD è facile da modificare le proprietà di non consentire agli utenti di chiudere / minimizzare webparts da una zona wp:

WebPartZone modificare le proprietà http://img34.imageshack.us/img34/3389/ webpartzoneedit.png

Ora, come possiamo farlo in codice? Ho più di pagine WebPart 30 aspx su un sito, voglio essere in grado di farlo in modo che nessuno può cambiare WebParts proprietà (vicino, li ecc cancellare.)

L'unica cosa che ho trovato è questo link:. spwebpartzonetools

lettura più in SDK all'indirizzo: WSS 3.0 SDK , a Importante, secondo comma, che dice:

Anche se è possibile aggiungere web part alla Visualizzare, modificare, e nuove forme per la lista articoli (DispForm.aspx, EditForm.aspx, e NewForm.aspx), così facendo non è raccomandato o supportato in Windows SharePoint Services. Aggiunta di web part a pagine List View (AllItems.aspx) è supportato.

Ecco, questo è il mio errore che voglio fix :). Ho fatto rompere questa regola. Il mio problema può essere risolto in SPD, ma non so se questo può essere fissato nel codice.

L'errore è stato "ispirato" da uno dei favolosi 40 modelli: BudgetingTrackingMultipleProjects.wsp . C'è nella lista progetti, su DispForm.aspx, Microsoft aggiungere più webparts per creare un modulo master-detail.

È stato utile?

Soluzione

Ho risolto il mio problema in questo modo: se si apre il DispForm.aspx in SPD e modificare le proprietà web di zona parte poi nel codice souce (aspx) possiamo vedere questa linea:

 <WebPartPages:WebPartZone runat="server" FrameType="None" ID="Main" Title="loc:Main" allowlayoutchange="false" allowpersonalization="false" allowcustomization="false">

Allora ho creato una console app semplice, che le visite a ciascuna lista, ottenere l'URL della sua DispForm.aspx e aprirlo come un normale file di testo. Quindi non sto usando qualsiasi API o si dovrebbe occupare, semplicemente SPWeb.GetFile (String) - per ottenere lo SPFile e SPWeb.GetFileAsString (url) per ottenere il contenuto aspx come corda. Poi sto iniettando gli attributi ( allowlayoutchange / allowpersonalization / allowcustomization ) nella linea presentata in precedenza utilizzando solo stringa di ricerca e sostituire i metodi.

quindi salvare la schiena contenuti in un file aspx utilizzando SPFile.SaveBinary (). Ecco fatto, la prossima volta DispForm.aspx si richiede la contrib. utente non può fare una cosa con webParts da lì. In modo che è il mio metodo al cambiamento web proprietà di zona parte. Sono così impaziente di vedere altre soluzioni.

Altri suggerimenti

You should be able to set these properties after provisioning the web parts (that is if you havent done as Chris say and defined it in the manifest of the web part) by iterating the web parts in the SPLimitedWebPartManager (beware of leak) on each page and set the AllowClose, AllowHide, AllowMinimize etc properties.

hth Anders Rask

You could also set this to the WebPartZone control (in code or in aspx). Use the LockLayout property, for instance like this:

<WebPartPages:WebPartZone LockLayout="true" runat="server"...>...</...>

/WW

Do you need to do it in code? If your requirement is simply to stop users making these changes in your web parts, this is typically dealt with by provisioning the web part with properties which specify this behaviour e.g.:

   <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
     <metaData>
       <type name="xxxxx.SharePoint.Common.WebParts.SiteDirectoryWebPartWrapper,
 xxxxxx.SharePoint.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx" />
       <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
     </metaData>
     <data>
       <properties>
         <property name="AllowZoneChange" type="bool">False</property>
         <property name="AllowHide" type="bool">False</property>
         <property name="AllowMinimize" type="bool">False</property>
         <property name="AllowClose" type="bool">False</property>
         <property name="AllowEdit" type="bool">True</property>
         <property name="AllowConnect" type="bool">False</property>
         <property name="ExportMode" type="exportmode">All</property>
         <property name="Hidden" type="bool">False</property>
         <property name="TitleUrl" type="string" />
         <property name="Description" type="string">Displays a list of sites
 for the current area (e.g. 'teams') in a treeview. </property>
         <property name="Title" type="string">xxxxx Site Directory
 Web Part</property>
       </properties>
     </data>   
    </webPart> 
</webParts>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top