Tag Info

Hot answers tagged

6

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


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"] = ...


6

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

SPList list = ... list.NoCrawl = true; list.Update(); See http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.nocrawl.aspx


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


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

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" />


4

There are 2 ways you can insert an image in a SharePoint master page. Both of them are relative url. 14 Hive (Physically hosted): You can place your images physically in the 14 hive folder under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES Place a image here (logo.png) and you can access this image in your ...


3

The only option is to create a custom editor part. Check out this msdn example.


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 }


3

SharePoint Server, not Foundation, offers a feature to use $SPUrl as a placeholder. So your url would look like this: <img src="<% $SPUrl:~sitecollection/sites/Style Library/Images/logo.jpg %>"> Here's some more info: http://thechriskent.com/2012/04/02/relative-paths-in-sharepoint-using-spurlexpressionbuilder-spurl/


3

You should never attempt to modify stuff in the SP database programatically. Doing so will put your SP into an unsupported state. Make a program or PowerShell script to update the SPList or SPListItem objects via the SharePoint API.


3

The configuration panel of the web part is called Tool Pane and you can open it using this simple JavaScript snippet : lblErrorMessage.Text = "<a href=\"javascript:MSOTlPn_ShowToolPane2Wrapper('Edit', this,'" + this.Parent.ID // Id of the current webpart + "')\">Edit Web Part</a>"; this.Parent.ID : return the WebPart ...


3

Use the following code: using(SPSite site = new SPSite("http://example/site/")) { using (SPWeb web = site.OpenWeb()) { SPWebCollection webCollection = web.GetSubwebsForCurrentUser(); foreach (SPWeb web in webCollection) { if (web.Properties["SiteCategory"] == "SomeCategory1") {} ...


2

We can also use: base.SetPersonalizationDirty();


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

My SPServices can help with this, using the Webs Web Service, GetWeb method.


2

Create an editor part for your Web Part: http://www.wictorwilen.se/Post/Web-Part-Properties-part-2-Editor-Parts.aspx


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

"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

There is a codeplex project which could give you an overview of how property bags can be used in SharePoint 2010 or 2007. Check this out - http://pbs2010.codeplex.com/


2

If you use Module, the file accessible by the URL. You should only activate feature that is installs this module to a web. After this you can use SPWeb.GetFile method.


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

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

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

I think it's actually: listitem["columnname"] in SharePoint 2007/WSS 3.0


2

The InternalNames are PublishingStartDate and PublishingExpirationDate If you want do it the "right" way then the IDs are in Microsoft.SharePoint.Publishing.FieldId.StartDate and Microsoft.SharePoint.Publishing.FieldId.ExpiryDate


2

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 = ...


2

Have you tried the Content Deployment Wizard to do this? http://spdeploymentwizard.codeplex.com/



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