Skip to main content

Element.xml explained

Some xml elements in Element.xml file in WSS 3.0:

1. Root element: Elements. It contains a Id attribute, which is a guid to uniquely identify this element.

2. Receivers element: This element is inside Elements. It contains ListTemplateId attribute which specifies what type of list will be attached to list item event handler. For example, a value of 101 means that the event handler will be attached to all document libraries.

3. Receiver element: This element is inside Receivers element. It contains several sub elements in it to define the class to receive list item event. A sample configure is like this:

<receiver>
<name>DigiDoc signature check event
<type>ItemUpdated
<sequencenumber>5000
<assembly>wssDigiDoc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=44b3223b8da05605
<class>wssDigiDoc.ddocEventHandler
</>

  • Name: A descriptive name
  • Type: The event type that this receiver class will handle. The possible values are: ItemAdd, ItemUpdate, ItemDelete...
  • SequenceNumber: It specifies the event firing order, if multiple event handlers are associated with the feature
  • Assembly: Fully qualified assembly name
  • Class: Class in the assembly that handles item level event
4. CustomAction: This defines the actions that are related to the feature
<customaction id="DigiDocSettings" groupid="SiteAdministration" location="Microsoft.SharePoint.SiteSettings" rights="ManageWeb" sequence="30" title="DigiDoc feature settings">
<urlaction url="_layouts/ddocsetting.aspx"></urlaction>
</customaction>
  • Id: The unique identifier for the custom action
  • GroupId: See Location attribute.
  • Location: This combined with GroupId defines where to put the action link. The possible value for Location are:
  1. Microsoft.SharePoint.SiteSettings, the site settings page. The GroupId then defines the which section in site settings page the action link should be put under. GroupId SiteAdministration will put the action link under "Site Administration" section on site settings page; GroupId SiteCollectionAdministration will put the action link under "Site Collection Administration" section; GroupId UsersAndPermissions refers to Users and Permissions section, etc.
  2. Microsoft.SharePoint.StandarMenu. The SharePoint standard menu. The GroupId can be: SiteActions, which means to put the action link in SiteActions menu on top right of page; SettingsMenu, which means the list's settings menu; ActionsMenu, which means the list's actions menu; NewMenu, which means the list's New menu; PersonalActions which means "Welcome (username)" menu on top of page.
  3. Microsoft.SharePoint.Administration.Operations: Operations tab in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
  4. Microsoft.SharePoint.Administration.ApplicationManagement: Application tabl in WSS central administration. The GroupId is GUID referencing the Id defined in CustomActionGroup. The Title attribute determines the text appearing as the link.
  5. EditControlBlock: The context menu when you move your mouse on list item. When the location is set to this value, you need to also to set RegistrationType and RegistrationId attribute to specify what type of list to apply the custom action.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomActionGroup
Id="BDDBB947-CBC6-47f7-B57A-6C8BEB0E19D7"
Location="Microsoft.SharePoint.Administration.Operations"
Title="Utilities"
Sequence="1000"/>
<CustomAction
Id="E57ECD33-91FD-4fc3-A4E8-E1B932178CB4"
GroupId="BDDBB947-CBC6-47f7-B57A-6C8BEB0E19D7"
Location="Microsoft.SharePoint.Administration.Operations"
Sequence="10"
Title="View Unified Logging Service"
Description="Displays Unified Logging Service (ULS) logs.">
<UrlAction Url="_admin/ULSLogViewer.aspx"/>
</CustomAction>
</Elements>
  • RegistrationType: Defines what type of data this custom action applying to. The possible value could be: List, ContentType, FileType and ProgId.
  • RegistrationId: When the RegistrationType is List, this RegistrationId specifies the types of list, for example, 101 mean document library, 104 means announcement; when the RegistrationType is FileType, the RegistrationId is the file name extension.
  • Rights: Specifies a set of rights that the user must have in order for the link to be visible, for example, "ViewListItems,ManageAlerts". If not specified, then the action always appears in the list of actions. To specify multiple rights, separate the values by using commas. The set of rights are grouped logically according to AND logic, which means that a user must have all the specified rights to see an action. For a list of possible values, see Microsoft.SharePoint.SPBasePermissions.
  • Sequence: Determine the display order of the action
5. Module: This element and File element (described below) are used to provision aspx files into SharePoint site. The Url attribute of Module element defines the root URL for all the files included in this module.

6. File: This element provisions the aspx file into SharePoint site. The Url attribute references the physical file deployed. The Name attribute defines the file name used by user. Type attribute specifies if this file is customizable. For example:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Url="Pages">
<File Url="ViewLog.aspx" Name=ViewClientLog.aspx Type="Ghostable" />
<Module>
</Elements>

The above element.xml will provision ViewLog.aspx file into SharePoint site. User should be able to access the file using http:///Pages/ViewClientLog.aspx

7. Field: The Field element defines the site columns that can be used in creating new column in list. The field definition schema is much same as the definition in list schema.xml file.
<field name="Digital Signers" id="{6251682B-A4A6-4cc4-BCE4-7C5247546CCD}" type="Note" title="Digital Signers" displayname="Digital Signers" description="Names of people who have signed this document digitally. Automatically updated" readonly="FALSE" showineditform="FALSE" showinfiledlg="FALSE" showinnewform="FALSE">
</field>
To use the field defined in element.xml file, use the following code snippet:
if (SPContext.Current.Web.Fields.ContainsField("MyFieldTitle"))
{
SPField field = web.Fields.GetField("MyFieldTitle");

if (!item.Fields.ContainsField(
field.Title))
{
item.Fields.Add(
field);
}
}





Comments

Popular posts from this blog

Manage IIS 7 remotely using PowerShell and AppCmd

We can use  Windows PowerShell remoting features  to manage IIS 7 websites remotely.  Currently, remoting is supported on Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2008 Release 2.  Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator .  Enable PowerShell Remoting with Enable-PSRemoting -Force Starting a Remote Session using:  Enter-PSSession -ComputerName <COMPUTER> -Credential <USER> Now the PowerShell connected to the remote server. Any commands issued with work against the remote server. We can use the Appcmd.exe command line tool to manage remote server just as what we do locally. For example, to add an application pool: c:\windows\system32\inetsrv\appcmd add apppool /name:"Contoso" /managedPipelineMode:Integrated /managedRuntimeVersion:"v4.0" /enable32BitAppOnWin64:true To change application p...

Entity framework code first error: OriginalValues cannot be used for entities in the Added state

When I was using Entity framework code first, I encountered an error when I tried to create an entity into database. The entity is: [ Table (" EmployeeProfile ")]     public partial class EmployeeProfile     {         [ Key ]         [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]         public int EmployeeProfileID { get; set; }         [ ForeignKey ("Employee")]         public int EmployeeID { get; set; }         public virtual Employee Employee { get; set; }         [ ForeignKey (" Profile ")]         public int ProfileID { get; set; }         public virtual Profile Profile { get; set; }       ...

X509Certificate2: The system cannot find the file specified.

When I use the new X509Certificate2(fileName, password, X509KeyStorageFlags.DefaultKeySet) to create certificate from certificate file containing private key in my web application, I got following error message: System . Security . Cryptography . CryptographicException : The system cannot find the file specified . at System . Security . Cryptography . CryptographicException . ThrowCryptogaphicException ( Int32 hr ) at System . Security . Cryptography . X509Certificates . X509Utils . _LoadCertFromBlob ( Byte [] rawData , IntPtr password , UInt32 dwFlags , Boolean persistKeySet , SafeCertContextHandle & pCertCtx ) at System . Security . Cryptography . X509Certificates . X509Certificate . LoadCertificateFromBlob ( Byte [] rawData , Object password , X509KeyStorageFlags keyStorageFlags ) at System . Security . Cryptography . X509Certificates . X509Certificate2 .. ctor ( Byte [] rawData , String password , X509KeyStorageFlags keyStorageFlags ) In orde...