Monday, March 31, 2008
Avoid enumerating SPListItemCollection object
Nice tip I have to remember for future development: Subhajit's blog
Wednesday, March 26, 2008
Unable to add selected Webpart(s)...
I got the error above in the following situation:
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.
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
This time we have to deal with a tough boy! The error has probably something to do with disposing of objects...
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:
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:
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".
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
Ok... another post about a great error. This time it's the lovely Page Layout Error:
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>
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
If you want to add some inline code in a masterpage or pagelayout file... you probably get the following error message:
<.pageparserpaths>
<.pageparserpath virtualpath="/_catalogs/masterpage/*" compilationmode="Always" allowserversidescript="true" includesubfolders="true".>
<./pageparserpaths>
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
Subscribe to:
Posts (Atom)