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

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


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

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


3

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

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

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


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

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

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

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


2

To my knowledge dates are stored as sequential serial numbers so they can be used in calculations. By default, December 31 1899 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Time also as part of a date value is also represented as decimal number (for example, 12:00 PM is represented as 0.5 ...


2

I can tell you where its going wrong! its here: cs.RegisterClientScriptInclude(this.GetType(), "jq", "/_layouts/js/jquery.js"); cs.RegisterClientScriptInclude(this.GetType(), "custom", "/_layouts/js/custom.js"); how do i know? well its simple! i presum as you said you have many instances of custom.js now this is where it gets messy, to put it ...


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

I believe you are referring to cascading drop downs in that values from one field filter the available options in another field. Sharepoint doesn't give you this type of functionality. It can be achieved with script (like SPServices) or Infopath.


1

I have discovered that the problem occurs when the Word file is based on a .dotx template. If the Word file is based on a .dotm template there is no problem. It seems that a multiple choise field can not be used on files based on a .dotx template, so the next thing to be solved, is to find out in which cases the template is a .dotx or .dotm. From my point ...


1

The metadata comes from the meta tags in the pages linked from the sitemap. DATATYPE is the name of a meta tag and TEXT is the data type. The meta tag was defined as: <meta name="DataType" content="bla bla bla...." />


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

If you have control of the property setting code of the web, you could have a quasi "index" in the RootWeb, which contains a csv or a list of webs with property values. Then, to find webs with specific properties, all you need to do is query a property from the RootWeb (which is a property from the SPSite so you don't need to do a search).


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

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



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