To get a collection of items from a list you can use SPQuery and CAML to filter and order the selected list:
SPSite oSite = SPContext.Current.Site;
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["ListName"];
SPQuery oQuery = new SPQuery();
oQuery.Query = "<OrderBy><FieldRef Name='Title' /></OrderBy><Where>"
+ "<FieldRef Name='Title' /><Value Type='Text'></Value></Where>";
SPListItemCollection oItems = oList.GetItems(oQuery);
To filter on date use the following to get any item that has been modified in the last 7 days:
string dateString = Microsoft.SharePoint.Utilities.
oQuery.Query = <Where><Geq><FieldRef Name=\"Modified\"/><Value Type=\"DateTime\">"+ dateString+"</Value></Geq></Where>
SharePoint Designer keeps adding spaces ( ) to my HTML in page layouts. This is particularly annoying as I am working to a web design that has been produced at great expense and the customer quite rightly expects that the developed website will match this exactly.
Unfortunately when I want:
<h4><PublishingWebControls:RichLinkField ID="RichLinkField1" FieldName="ByProductType1" runat="server"></PublishingWebControls:RichLinkField></h4>
<p><SharePointWebControls:TextField ID="TextField4" FieldName="ByProductTypeDesc1" runat="server"></SharePointWebControls:TextField></p>
What I get is:
<h4> <PublishingWebControls:RichLinkField ID="RichLinkField1" FieldName="ByProductType1" runat="server"></PublishingWebControls:RichLinkField></h4>
<p> <SharePointWebControls:TextField ID="TextField4" FieldName="ByProductTypeDesc1" runat="server"></SharePointWebControls:TextField></p>
Hopefully this will be fixed in a service pack but for now I am having to edit my page layouts in Visual Studio and then drag and drop the aspx file into the masterpage library within SharePoint designer. The HTML editor in Visual Studio is much better behaved and does not add in the unwanted spaces.
theKid has found another issue, which I have not experienced, with closing tags being lost by SharePoint designer. Read more about that here...
I have just been tidying up my masterpage library in a WCM sitecollection and came across an issue when trying to delete some master pages.
When trying to delete I got the following error:
I know that this is not the case - no other pages use this master page!
Fortunatley there is a workaround for this. Simply create another folder in the masterpage folder and then drag the master page you want to delete into it. Then delete the folder and your master page is gone.
Thanks to Katrien De Graeve for this solution.
If you name a site or page with an & and you want to also use the breadcrumb SiteMapPath control then you are going to see some nasty results. This is because the control outputs "&amp;" instead of "&".
To fix this you need to make a change to the sitemappath control. Simply include SiteMapProvider="CurrentNavSiteMapProviderNoEncode" as follows:
<asp:SiteMapPath runat="server" id="SiteMapPath1" PathSeparator="|" SiteMapProvider="CurrentNavSiteMapProviderNoEncode"></asp:SiteMapPath>
So you are trying to use a custom css in your master page but the nice shiny font you are trying to display isn't showing up! The reason for this is that core.css will be called after your custom css file leaving your text displaying as verdana or arial.
The fix for this is to declare your custom css file in the master page settings of your site - (Site Actions/Site Settings/Master Page). The result is that your custom css will be applied after core.css and the font you specified is used.
For more interesting scenarios in which a bit of tweaking is required to get the right css file to be applied see http://www.heathersolomon.com/blog/archive/2006/10/27/sp07cssoptions.aspx
My colleague Andrew Westgarth is currently in Barcelona at Tech-Ed - lucky bugger! See his round up of the first couple of days action.
I recently needed to add a reference to a web part where the dll had not been strongly named. The result of doing this was a build error complaining about the unsigned dll. I did not have access to the source code so couldn't resolve the issue by rebuilding the dll with a strong name. Instead I used the ILMerge tool which can be found here.
Rather than using the tool for it's intended use of to combining a number of dlls into a single dll I used it to sign my single dll using the following command line syntax:
ILMerge.exe /out:c:\signed.dll pathToFile\unsigned.dll /keyfile:pathToFile\aidangarnish.snk
I have been writing some code that retrieves unread Outlook messages and displays today's appointments to a user. This KB article has it covered: http://support.microsoft.com/kb/310265