Monday, March 31, 2008
Avoid enumerating SPListItemCollection object
Wednesday, March 26, 2008
Unable to add selected Webpart(s)...
I developed a custom masterpage and on that masterpage I added a Label control. Afterwards, the label is filled up with some list data (in my case: information from a page library) . Maybe I could work with a webpart, but I don't think it's evident to put a webpart on a masterpage.
Everything worked fine until I saw that I coudn't add any webpart anymore. Believe me, it was hard to find out the cause of the problem. After excluding many possibilities I discovered that it was something in my masterpage. And guess what ... my innocent label was the cause of the whole thing!
Solution:
Because of the fact that my code works fine in DisplayMode of a page, I surrounded my code with the following condition:
if (SPContext.Current.FormContext.FormMode.Equals(SPControlMode.Display))
{
//Populate the "innocent" label
}
The condition will check whether you are in DisplayMode are not... If so... populate the label.
The mysterious 0x80020009 Error
I wrote a contact webpart, who has several custom properties to set the labels and some other info (SMTP Server name, Success Message, etc.). When I added my new webpart to the page and set the properties - everything works fine. But... when I modified the text of a label, I got the following error message:
Cannot save the property settings for this Web Part. Exception occurred.
(Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
The first thing you do when you see an error like that is to verify the ULS Logs and take a look at the eventviewer. The eventviewer indicated no problem.
The ULS Log gave me the following message:
Trying to store a checked out item (/page.aspx) in the object cache. This may be because the checked out user is accessing the page, or it could be that the SharePoint system account has the item checked out. To improve performance, you should set the portalsuperuseraccount property on the web application. See the documentation for more information.
So I:
--- removed the webpart
--- added him back to the page
--- modified the custom properties ... works ok (surprisingly!)
--- a couple of hours later... modified it ... didn't work anymore!
I haven't found a solution for it...
Hezser talked about disposing SP objects correctly - but in my webpart I don't use SPWeb, SPSite, etc... . I'll update this post when I get more information.
Worth to mention: The same webpart and thus the same code works fine on my developing machine. Spooky!
Hezser blog (Dispose SP objects correctly)
Paul Gavin's SharePoint Space (no solution yet)
Update: I discovered that my custom webpart is not the only victim. Other webparts are poisoned as well.
Solution: My "innocent" label was the cause of the problem. See my next post about "unable to add selected webpart".
Friday, March 21, 2008
The ErrorLady loves me
Only Content controls are allowed directly in a content page that contains Content controls
It's unnecessary to write down my whole story because Rich Finn already made an excellent blogpost about it.
Let me summarize Rich Finns story in a oneliner: Make sure that the ASP Content tag starts with a capitalized letter <.asp:Content>
Code Block are not allowed in this file
To get this working you need to modify the web.config of your web application. For instance, if you want to allow server side script on pages from the masterpage & pagelayout gallery you have to modify the PageParserPaths into:An error occurred during the processing of blabla.aspx. Code blocks are not allowed in this file.
<.pageparserpaths>
<.pageparserpath virtualpath="/_catalogs/masterpage/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true".>
<./pageparserpaths>
Tuesday, March 18, 2008
Configure anonymous access (Office SharePoint Server)
Some links about this topic:
- How to enable anonymous access for a site collection and disable anonymous access for sub-sites.aspx
- Technet: Configure anonymous access
- MS: Enable anonymous access
- Anonymous Users In SharePoint (Part 1) : Introduction
- Anonymous Users In SharePoint (Part 2) : Solutions
- Anonymous Users In SharePoint (Part 3) : Welcome Guest
Wednesday, March 12, 2008
Tuesday, March 11, 2008
Solution Deployment Failed
Failed to extract the cab file in the solution
just verify if you have used special characters like é,ä,ö,å, etc. in the name of the files you want to provision. For example: If you build a pagelayout and you give him the name "ManagementComité.aspx" ... the solution deployment will fail. Be aware of this issue in the future.
Monday, March 10, 2008
Display choices using checkboxes (allow multiple selections)
The MOSS SDK says the following about the Format attribute:
For Choice fields, this attribute can be set to Dropdown (default), which provides editing options through a drop-down selection, or to RadioButtons, which provides options through a group of radio buttons.
If you have already created a choice site column with the UI in SharePoint you will have noticed that you have several display modes of a choice field:
Display choices using:
- Drop-Down Menu
- Radio Buttons
- Checkboxes (allow multiple selections)
So I thought the display modes were related to the Format Attribute of the Choice field (Isn't that logic?). I was wrong! After a while I found another (the correct) type to realize a multichoice checkbox thing. The type is "MultiChoice":
Specifies a Choice field that implements check boxes and allows the user to select multiple values.
An example of how to make a multichoice field with a feature...
<.Field ID="{EB21EEF7-9B67-4eb8-8CC9-15F76264121F}" Name="Vacature Product" Group="Vacature Page Layout Site Columns" DisplayName="Product" SourceID="http://schemas.microsoft.com/sharepoint/v3/fields" StaticName="Vacature Product" Type="MultiChoice" Required="TRUE" FillInChoice="TRUE">
<.CHOICES.>
<.CHOICE>Marketing & Product Management<./CHOICE.>
<.CHOICE>Sales & Services<./CHOICE.>
<.CHOICE>Productie<./CHOICE.>
<.CHOICE>Redactie<./CHOICE.>
<.CHOICE>ICT & Design<./CHOICE.>
<.CHOICE>Human Resources<./CHOICE.>
<.CHOICE>Financieel & Business analyse<./CHOICE.>
<./CHOICES.>
<./Field.>
After the site column creation, you can use this fieldtype in a pagelayout with the CheckBoxChoiceField class.
Example:
<.SharePointWebControls:CheckBoxChoiceField FieldName="Product" runat="server" ID="CheckBoxChoiceField1"/.>