/// <summary> |
/// This will enable the Enterprise Keyowrds for the associated lists |
/// </summary> |
/// <param name="properties">from list event</param> |
private void EnableEnterpriseKeywords(SPListEventProperties properties) |
{ |
//get an instance of list to be enabled with keyword |
SPList list = properties.List; |
//get an instance of SPTaxonomy assembly |
Assembly taxonomyAssembly = Assembly.LoadWithPartialName("Microsoft.SharePoint.Taxonomy"); |
//get an instance of internal class for the keyword association |
Type listFieldSettings = taxonomyAssembly .GetType("Microsoft.SharePoint.Taxonomy.MetadataListFieldSettings"); |
//pass the list to the internal class's constructor |
object listSettings = listFieldSettings.GetConstructor(new Type[] { typeof(SPList) }) |
.Invoke(new object[] { list }); |
//get an instance of KW property and set the boolean |
listFieldSettings.GetProperty("EnableKeywordsField", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue(listSettings, true, null); |
listFieldSettings.GetProperty("EnableMetadataPromotion", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(listSettings, true, null); |
//update the list listFieldSettings.GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance) .Invoke(listSettings, null); |
} |
Please format the above code J |
Friday, April 22, 2011
Add Enterprise Keywords Column Programmatically For SharePoint Lists
Monday, April 18, 2011
Performance Of SharePoint List Access Methods
P.S: The above data is extracted from Developer Dashboard, by enabling the SPMonitoredScope for each access mechanism.
Monday, April 4, 2011
Access Denied On IISReset
Problem:
“Access denied, you must be an administrator of the remote computer to use this command. Either have your account added to the administrator local group of the remote computer or to the domain administrator group”
This is a common problem for those who have just started SharePoint 2010 development on newly installed Windows Server 2008/Windows 7 OS. Though you have the administrator rights on the computer, the default security mechanism in the OS itself enable the UAC (User Access Control) to higher level which blocks certain activities from doing deliberatively. One of such situation causes the IISRESET command to be failed, reporting the above error.
Solution:
Set the UAC to “Never Notify” level and make sure that you Restart the computer. Now the problem solved J