Tag Info

Hot answers tagged

6

A good way to visualize this and to learn more about the structure of the property bags is to use SharePoint Manager and just browse the DOM. http://spm.codeplex.com/ For example to access the property bag of the root folder in a list you can use this code: string someProperty = "Some data to store"; MyList.RootFolder.Properties["YourProperty"] = ...


5

The various property bags are backed by Hashtable objects, except for SPWeb.Properties which is a StringDictionary (essentially a strongly-typed, non-generic Hashtable). SPWeb.AllProperties is a Hashtable and is prefered to AllProperties (it also does not force lowercase key values). The performance of all these containers is excellent (see for example ...


5

Ideally, you should neither set or reset the value of AllowUnsafeUpdates. Instead use the SPUtility.ValidateFormDigest and that's it. This sets AllowUnsafeUpdates = true for the current HTTP request. The reason you should never set the AllowUnsafeUpdates = false is that other code might use SPUtility method an rely on that it was earlier asserted. Than your ...


4

No, as you can see from the msdn documentation, the SPList object does not have a "Property Bag" property. That said, if you need to, a common workaround is using the property bag of the root folder of the list as a surrogate. You see... SPFolder does define a property bag. Also you can take for granted that a (normal) list or document library should have a ...


4

Don't make property List static EDIT: Working code: [ToolboxItemAttribute(false)] public class MyDetailWebPart : WebPart { ... [Personalizable(PersonalizationScope.Shared)] [WebBrowsable(true)] [Category("Category")] [WebDisplayName("Name")] [Description("Desc")] public string Code { get; set; } ... protected override void ...


3

Check if listItem.Properties["columnName"] is null And you don't have to go through a string if not just use (bool)listItem.Properties["columnName"] So a full test could be: if (listItem.Properties["columnName"] != null && (bool)listItem.Properties["columnName"]) { // Checked } else { // Not Checked }


2

Try this public class CustomWebPart : System.Web.UI.WebControls.WebParts.WebPart { private int _instanceId = 0; [Personalizable()] public int InstanceId { get { return _instanceId; } set { _instanceId = value; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!Page.IsPostBack) { ...


2

"If you are going to use AllowUnsafeUpdates, there's no need to reset it to its previous value. It does not get persisted. It's just something you need to set on an SPWeb object before performing updates from a GET (or other cases)" from this question: http://stackoverflow.com/questions/213882/best-pattern-for-allowunsafeupdates


2

To detect concurrent edits SPPersitedObjects use an internal version number that is incremented on each successful write. When you obtain a reference to an SPPersistedObject the version number at that time is remembered in your copy of the object. When you make a change to your copy and try to .Update() it into the database SharePoint compares the version ...


2

As suggested here: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/1f42e45e-160f-457d-b4dd-cb228e49abb7 You should use following fields along with UpdateOverwriteVersion() method to update fields such as author, date created etc. // The actual User Information is within this SPListItem SPListItem userItem = ...


2

Just to complete the answer provided in the link. If your property bag value is a plain text, not a serialized xml settings (as in the other question), you can use get_item function directly: function getWebPropertyValue(key) { var ctx = SP.ClientContext.get_current() var web = ctx.get_web() var props = web.get_allProperties() ...


2

How do you retrieve Extended Properties? I used this code in my castom form in the past. I think it should work in event receiver. Hashtable extendedProperties = SPWorkflowTask.GetExtendedPropertiesAsHashtable(taskItem); var value = extendedProperties[key].ToString();


2

I think your URL is wrong. It should be just <img src="/Style Library/Images/logo.jpg" /> If you want to have it accessible from another sitecollection I suggest you deploy the image to the "/_layouts/images" folder instead. Thereby you can alwas reach it by just using the relative URL: <img src="_layouts/images/logo.jpg" />


2

Sharepoint has tokens you can use which will be replaced at runtime ~site – Web site (SPWeb) relative link. ~sitecollection – site collection (SPSite) relative link. Agree with Robert that you would probably want to deploy it to the layouts folder. The url you have given points to a specific library, unless you're planning to deploy the logo to each site ...


1

You can create an element manifest property bag for a file, folder, list item, or website. For example: <PropertyBag HyperlinkBaseUrl="http://contoso.com/sites/EastEnglandSalesOffice"" Url="Lists/CurrentDiscounts" ParentType="ListItem" ItemIndex="23"/> <Property Name="DaysToLive" Value="90" Type="int" /> </PropertyBag> Reference: ...


1

I've found a way of doing it, but not sure at all it is the good one! I've put the attribute as a static public attribute, so I can access from the class, and it's the good values ! But please if you know how to do that more properly, tell me :) EDIT : Ok, totally found what i wanted : using Dependency property as shown here : ...


1

As stated problem was with item.Properties.ContainsKey("Is it Important"); I couldn't find out what caused this weird behaviour but I find a work around which is going through each SPField and check if my field exists or not using title. private bool IsFieldThere(string ColumnName, SPListItem item) { SPFieldCollection fieldCollection = item.Fields; ...


1

This blog provides a good overview of how to work with the SPWeb property bag while also providing links to MSDN. http://bramnuyts.be/2012/01/10/working-with-spwebs-propertybag/ The root of your problem, it seems, is that you are doing SPWeb.AllProperties.Add() instead of SPWeb.AddProperty()


1

You could try: item.get_fieldValues().MetaInfo Full example (with ES5): var listTitle = 'TestList', itemId = 1; var ctx = new SP.ClientContext(); var item = ctx.get_web().get_lists().getByTitle(listTitle).getItemById(itemId); ctx.load(item); ctx.executeQueryAsync(function() { var properties = item.get_fieldValues().MetaInfo; properties = ...


1

If you already have an instance of either the parent List of ListItem you could easily check whether the particular field does exist (e.g. if you use multiple content types you could try directly on the content type), by using one method of the Fields property of type SPFieldCollection - see here for more details ...


1

In Copy action, you should retrieve list item values and save them somewhere. Clipboard is not a good choice here, because some browsers don't accept direct access to the clipboard. Thus, I can propose HTML5 local storage, which is at the moment supported by all the modern browsers. You can find details on HTML5 local storage here: ...


1

Do you have permissions? Perhaps they used PowerShell? When you say "years ago" I assume we're talking SP 2007? http://nickgrattan.wordpress.com/2007/09/03/preparing-powershell-for-sharepoint-and-moss-2007/ http://www.powershell.nu/2009/09/08/moss-2007-script-collection/ Here's a start. Hope that helps. ...


1

It sounds like what you have is a configurable component. If that is the case, you should implement configuration properly instead of hacking/reflecting an object to make is suit your purpose. The patterns & practices group discusses configuration in "The Application Setting Manager" section of their guidance. The guidance also includes sample code for ...


1

It's not possible throught Enable-SPFeature if you need it you'll have to write your own cmdlet, there a guide for doing that here In that cmdlet, you can use the reflection hack you linked to, but note that when you're using reflection to find non-public methods you run the risk of any update/hotfix/SP breaking your code.


1

Have you added the properties you want to retrieve in the Managed Properties section of the Service Application? Note that this is different from the 'Managed Metadata' Service Application (perhaps poor naming on MS' part). You'll also want to ensure that the Managed Properties you have are included in the index.


1

You will need to build a custom BCS connector to achieve this, as opposed to a ".NET" connector. This is the approach to use where the back-end system is not static. There is a comparison between the two types of VS2010 connector on MSDN. Whilst this is the general approach you might use, what you are trying to achieve will require a considerable amount of ...


1

When you want to appear custom properties in the webpart properties and you don't want to create an editor part, which is not that difficult at all!, you can mark the properties WebBrowsable. The propery will show up in the Miscellaneous section. More information can be found here: ...


1

I think you answered your own question in your comment: So I better go for using getter and setter methods with different keys for the viewstate. You can have a unique key with 'this.ID', which give you the webpart 'guid'. If you want to share similar logic between webparts or controls in general, you can also create a static 'helper' class.


1

The user profile service is dependent on the Managed Metadata service in SharePoint 2010. A lot of profile properties will show as disabled if your Managed Metadata service is not set up correctly. There is a blog post on setting up a custom property using term sets here.



Only top voted, non community-wiki answers of a minimum length are eligible