API for interacting with SharePoint from .NET code deployed to the server.

learn more… | top users | synonyms

0
votes
2answers
659 views

Add site column to site content type error

var objWeb = properties.Feature.Parent as SPWeb; Guid webPublishingGuid = new Guid("94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb"); SPFeature feature = null; SPSite site = objWeb.Site; feature = ...
3
votes
1answer
5k views

How do I query a list using CAML and SPQuery?

I have a SPList but I don't need to go through everything in that list. I need to establish a CAML query so I can limit the list items. Then, go thru each item from the query result and do something. ...
1
vote
2answers
350 views

Powershell calling custom code has SPWeb.CurrentUser = null (in certain cases)

I have a custom assembly which contains code to setup Variations for a SharePoint 2010 Publishing site. This code is based off a blog post from Waldek I have a PowerShell script in which I create a ...
4
votes
1answer
2k views

How to find the Author Name using SP Client Context in SharePoint 2010?

I am trying to find the Author Name(created by) for a given Item Id using the SP Client context in SharePoint 2010. Below the code snippet var ctx = new SP.ClientContext.get_current(); ...
6
votes
2answers
204 views

Choosing between API and web services

We are designing a system where we will have a service facade, behind this facade will be functionality to update SharePoint. For example to move an item from one list to another. What we are ...
2
votes
4answers
322 views

Document Library throws NullReferceException everytime I try to grab an item

This code is from a sequential workflow. I am trying to grab the most recent item in a document library. I check to make sure there are more than zero items in the library, then I try to grab the most ...
3
votes
3answers
6k views

Sharepoint 2010: Custom “New Item” form - showing ribbon and binding events to ribbon buttons

We've created a custom New Item page for our list on our site in Sharepoint 2010 with this code: <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <table ...
1
vote
2answers
2k views

Why httpcontext.current is null in sharepoint 2010 while Implementing the Custom Membership Provider?

SharePoint 2007 we can able to use the Httpcontext.current object But in SharePoint 2010 we are unable to get the httpcontext.current object. It will return the values. How can i get the or Create ...
3
votes
4answers
9k views

Make a copy of sharepoint site under a new name

Since we can't save SharePoint site (with publishing feature enabled) as Template, I'm looking for a way to do this programmatically : Make a copy of "SiteA" with a new name "SiteB" under the ...
5
votes
3answers
2k views

Should I dispose SPWeb or SPList?

I am doing a whole bunch of things with one SPWeb and many SPLists. If I just dispose web in the finally section would that dispose all of SPLists that I instantiated? (btw, I understand the concept ...
3
votes
1answer
470 views

Possible to get all SiteCollections in a WebApplication from SPContext.Current?

I would like to look at all Site Collections that are in the current web application based on SPContext.Current. Is there a way to do this? If not, how can I achieve this?
6
votes
1answer
3k views

Fastest way for looping through a SPWebCollection

I've developed a console application for looping through all the webs inside my SharePoint 2010 site, but it's kind of slow, until the point that it throws OutOfMemory exception. This is the code I ...
2
votes
1answer
309 views

Why do I sometimes have to use different SPQuery tags?

Every SPQuery's query should have <View><Query> query... </Query></View> tags? Sometimes I have to put without those tags to get it work and some times I have to put it ...
9
votes
3answers
3k views

Is there a way to see if an SPField was created by a user?

I have some code where I am going through all of the Fields that belong to a content type. I'm curious if there is a way to check to see if the SPField was created by a user or if it is a system ...
0
votes
1answer
255 views

RefinementWebPart - UseDefaultConfiguration property

I'm trying to create a filter dynamically through code, and for that I need to set the property UseDefaultConfiguration to false. However, just this simple thing below causes the webpart to "hang" on ...
2
votes
2answers
1k views

Getting SPList object by Guid giving exception “List…does not exist at site with URL”

I am trying to load a drop down list with the same items that a lookup field uses. I thought it would be relatively straightforward, but the line SPList lookupList = ...
2
votes
1answer
322 views

Setting the value of a custom web part property using object model

Let's say I have a reference to a web part that I got by using a SPLimitiedWebPartManager. How can I set the custom properties of that web part? For example, if it is a stock ticker web part, how do I ...
2
votes
2answers
212 views

Sharepoint Web Part restrict to zone

Is there any way to restrict a web part to a certain zone? I know I can restrict it by using the AllowZoneChange flag, but is it possible to make sure the web part can only be added to certain zones? ...
0
votes
1answer
156 views

SharePoint Web Part Gallery details of each web part

When using SPWeb.GetCatalog(SPListTemplateType.WebPartCatalog), it returns an SPList which of course contains a SPListItemCollection of the web parts in the web part gallery. When looping through the ...
1
vote
1answer
213 views

SPWeb.Webs, foreach and var

See below: SPWeb currentWeb = SPContext.Current.Web; foreach (var web in currentWeb.Webs) { // web is object here - why? } SPWebCollection implements IEnumerable<SPWeb> (among other ...
1
vote
1answer
759 views

Programmatically enumerating Web Part Zones of a Publishing Page Layout

I have a situation where a class I have is passed a PublishingPage instance and I want to enumerate any and all web part zones that are used in the Layout Page for this page. This is proving tough. ...
0
votes
2answers
322 views

Sharepoint 2007 Current User ObjectModel

I'm trying to use the object model of Sharepoint 2007 to make some changes over a list and read users and groups web settings... For that I developed a Web Service (WCF) that is stored in the same ...
0
votes
1answer
541 views

Re-order Content Types for a List in code

Has anyone been able to re-order content types for a list in code? If I'm given a specific content type, I want to make it the default in a list, by re-ordering the SPList.ContentTypes collection and ...
3
votes
1answer
696 views

SPLongOperation never ends

I have an SPLongOperation that occasionally fails to redirect the user to a new page when the operation completes. I'm not sure what circumstances cause the problem, since I don't yet have a reliable ...
0
votes
1answer
1k views

Add an item with lookup field using object model SP2010?

Can someone please post sample code which shows how to deal with a lookup column during an item insert (using object model). Here is the basic framework for an insert: SPListItem oListItem = ...
2
votes
2answers
1k views

Set custom publishing page layout custom field programatically

I have a custom publishing page content type, based on the Publishing Article Page content type. On this content type, I have a custom field named "PageContentCategory". In my code to create new ...
1
vote
1answer
647 views

Custom ECB dropdown menu API?

In 2010 (or 2007) is there a server control that is responsible for rendering of ECB menus? For example, if I wanted to create a custom UI for a Document Library (NOT using XSL/DataViewWebPart/etc), ...
0
votes
3answers
411 views

How to find newly added item in the sharepoint portal?

How to find the recently added item in the share point page If the any user added the items in the custom list, library, list,Announcement, Picture library,etc......... i need to show all item that ...
0
votes
1answer
243 views

SPListItem IsNew Functionality?

In OOB SharePoint, many of the lists render a "New" graphic when an item is "New". I found this posting which indicates how to determine this from an XSL file: ...
0
votes
1answer
2k views

Event SPListItem Recurrence Text?

Is there a way to get the text displayed for the "Recurrence" field on the View Item screen for an OOB "Event" list item through the object model? For example, I see: "Every 1 month(s) on the first ...
0
votes
2answers
971 views

SPList.GetItems(query) does not return SPListItems where the permissions are not inherited

I'm using the following code: protected void TraverseFolder(SPList list, SPFolder folder) { SPQuery qry = new SPQuery() { Folder = folder }; SPListItemCollection listFolderItems = ...
2
votes
2answers
504 views

How to enable custom ordering on a list?

I want to be able to create a list programmatically which allows end users to reorder the items in the list. There appear to be 2 steps to this. Firstly set the SPList.Ordered property to true - this ...
2
votes
4answers
1k views

WCF Service @ SharePoint 2010 TimeOut

I have been developing on SP 2010 for a while now. Mostly I have been working with the Client Object Model. Though I am at a point where I need to read out the UserProfiles from inside SharePoint. ...
1
vote
3answers
566 views

Accessed denied when attempting to permission folder using the Object Model API

I'm attempting to permission a folder using the Object Model API that is created by an ASP.NET page wrapped into a feature. I am able to create and permission the folder for users that are in the ...
1
vote
2answers
1k views

Can I export a SharePoint 2007 list to an Excel file subdivided into separate worksheets?

We have a SharePoint 2007 deployment which will have a substantially large document library. My client wants the ability to export this library to an Excel spreadsheet, but specifically wants the ...
2
votes
1answer
746 views

How is a link to a Meeting Workspace stored for a Calendar Event?

If you open the DispForm.aspx for an item in a Calendar List, you see a link and display text to the Meeting Workspace (if one exists) for that event. How can I access the link to the Meeting ...
6
votes
1answer
3k views

Checking existence before using GetItemById

I am getting an item by using GetItemById but I want to check before using it whether the item exists or not. I don't want to use a query as the main purpose of using GetItemById is performance. ...
2
votes
2answers
648 views

How do I query several lists with the Object Model and merge the results?

Is it possible to with the Object Model query several lists at the same time and get the result merged together? Something like linked sources in SharePoint Designer? I have created a web part that ...
3
votes
3answers
953 views

Problem with SPList.SaveAsTemplate

I have never really had too much cause to use this method before but I am developing some generic classes to deal with column, content type and list management for use in a series of features. My ...
1
vote
5answers
1k views

for vs foreach when iterating over SPWebCollection

I was just wondering which of the two methods below is more popular, when it comes to iterating over a collection of SPWeb objects. for (int i = 0; i < SPContext.Current.Site.AllWebs.Count; i++) { ...