Prevent windows being maximized when moved to top or side off screen

November 12th, 2010 No comments

Do you also hate that Windows 7 or Server 2008 automatically maximizes your windows when you move them to the top or side of the screen? You can disable this with the following option. Go to the Ease of Access center in control panel.

Select option make mouse easier to use. Disable the following option:

Categories: Windows, Windows 7, Windows Server 2008 Tags:

Installing Sharepoint 2010 on Windows 2008 (R2) domain controller installs SQLExpress

November 12th, 2010 No comments

When installing Sharepoint server on a Windows 2008(R2) server that has the role of domain controller the installer skips the step in which you can choose what type of installation you want. The stupid thing is that Sharepoint installs a stand alone installation. In my case I already have SQL server 2008 R2 installed so I want a farm installation. The trick is tp pass a config file to the Sharepoint executbale. Take these steps for a correct famt install

  • Start setup.exe and install prerequisites ( autorun DVD)
  • Exit the setup screen
  • Open a command window and navigate to your DVD folder
  • Start the setup and with the following param

Where e: is the drive containing your Sharepoint DVD

e:\setup.exe /config e:\Files\SetupFarm\config.xml

This will install a farm installation. After installation you can configure a new or existin farm

Sharepoint 2010 User Profile Synchronization hangs on starting

November 12th, 2010 No comments

After installation off Sharepoint 2010 I tried to start the User Profile Synchronization service. After pressing start the service stayed on the status starting for ever. See screenshot:

When trying to manage synchronization form user profile management screen I got the alert:

Cannot navigate to the requested page while User Profile Synchronization is running.Please wait for the current Synchronization run to finish

So I checked my installation. I have a special AD account for use with all Sharepoint services. This account was not in thelocal Admin group. So I added the account and still it wouldn’t start.Adding the user to the local admin group should be enough. It seems that my user profile service got corrupted. So I decided to delete my User Profile env and recreate it.

After recreating I tried to start the User Profile Synchronization service. It now starts

In the services management console the fore fron services are now working

And my server is syncing profiles

Windows 2008 R2, Office 2010 protected view

November 12th, 2010 No comments

I recently installed a new Windows 2008 R2 server system on my laptop for Sharepoint development. After installation of Sharepoint 2010 & Office 2010 I got strange errors opening Office files from internet and even from my own Outlook archive. I got these errors in Word and Powerpoint:

I had the same installation on a Windows 7 box so I started looking for differences. When opening Office files like Word or Excel they are opened in protected view on my Windows 7 machine. So could this be my problem? I disabled protected view in Word, Excel and PowerPoint and now everything works.

So disable the following options if you use Windows 2008 (R2) on your workstation and you are experiencing errors opening Office files.


Go to Trust Center menu and click on the button Trust Center Settings.

My new Sharepoint development box

November 11th, 2010 No comments

Why of Why does Sharepoint need such a system!!!

Categories: Sharepoint Tags:

Getting localized pages listname & url (PublishingWeb.GetPagesListName(web))

November 5th, 2010 No comments

In a piece of code I wrote I had to access the pages list. I had to do this on English and Dutch site. So to get the name  for the pages list I used the function

PublishingWeb.GetPagesListName(web) On my English site this worked fine. On my Dutch site it didn’t work. So I started to trace what was happening. This is a short example

of the code in a console application

try
{
string SiteUrl = ConfigurationManager.AppSettings["SiteUrl"];
using (SPSite oSPSite = new SPSite(SiteUrl))
{

using (SPWeb web = oSPSite.OpenWeb())
{

SPList pagesList = web.Lists[PublishingWeb.GetPagesListName(web)];

SPListItemCollection allItems = pagesList.Items;

Console.WriteLine(allItems.Count.ToString());

}
}

Console.ReadLine();

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);

}

On my English site the name of the pages list = “pages” and url = “pages.” The result off the function PublishingWeb.GetPagesListName(web) gives back “pages” so no problem.

On myDutch site the name of the pages list = “Pagina’s” and the url = “paginas”. When executing the fuinction on my Dutch site I get the result “paginas”. So the function PublishingWeb.GetPagesListName gives back url and not the name. When I try to access the list

SPList pagesList = web.Lists[PublishingWeb.GetPagesListName(web)];

I am trying to get this

SPList pagesList = web.Lists["paginas"];

witch gives an exception because this list doesn’t exist. What I need to do is:

SPList pagesList = web.Lists["pagina's"];

So I found a trick to make this work There is also a function called PublishingWeb.GetPagesListId This gives back the guid Id of the list. So this works fine

SPList pagesList = web.Lists[PublishingWeb.GetPagesListId(web)];

With thanks to Jeremy Jameson

Custom Action Definitions for SharePoint 2010

November 2nd, 2010 No comments

The custom actions for Sharepoint 2010 mentioned on MSDN
are not correct. Use these custom actions and locations:

Location Custom Action Group ID Description
Microsoft.SharePoint.Administration.

Applications

WebApplications Web Applications section under Aplication Management on Central Administration
SiteCollections Site Collections section under Aplication Management on Central Administration
Databases Databases section under Aplication Management on Central Administration
ServiceApplications Service Applications section under Aplication Management on Central Administration
Microsoft.SharePoint.Administration.

SystemSettings

Servers Servers section under System Settings on Central Administration
Email E-Mail and Text Messages (SMS) section under System Settings on Central Administration
FarmManagement Farm Management section under System Settings on Central Administration
Microsoft.SharePoint.Administration.

Monitoring

HealthStatus Health Analyzer section under Monitoring on Central Administration
TimerJobs Timer Jobs section under Monitoring on Central Administration
Reporting Reporting section under Monitoring on Central Administration
Microsoft.SharePoint.Administration.

Backups

FarmBackup Farm Backup and Restore section under Backup and Restore on Central Administration
GranularBackup Granular Backup section under Backup and Restore on Central Administration
Microsoft.SharePoint.Administration.

Security

Users Users section under Security on Central Administration
GeneralSecurity General Security section under Security on Central Administration
InformationPolicy Information policy section under Security on Central Administration
Microsoft.SharePoint.Administration.

UpgradeAndMigration

Patch Upgrade and Patch Management section under Upgrade and Migration on Central Administration
Microsoft.SharePoint.Administration.

GeneralApplicationSettings

ExternalServiceConnections External Service Connections section under General Application Settings on Central Administration
SiteDirectory Site Directory section under General Application Settings on Central Administration
SPD SharePoint Designer section under General Application Settings on Central Administration
Microsoft.SharePoint.Administration.

ConfigurationWizards

FarmConfiguration Farm Configuration section under Configuration Wizards on Central Administration
Microsoft.SharePoint.SiteSettings UsersAndPermissions
Customization
Galleries
SiteTasks
SiteAdministration
SiteCollectionAdmin
CommandUI.Ribbon

Custom Sharepoint userfield webcontrol. Generate mailto

September 18th, 2010 No comments

When I was using the userfield to display to username of a selected user or group I wanted this field to display username and email adres. Si I create a custom control to display name and generate a mailto link:

using System;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
using System.Web.UI;

namespace Webcontrols
{
   public class EnhancedUserField : UserField
   {
      protected override void Render(System.Web.UI.HtmlTextWriter output)
      {
         if (this.ItemContext.FormContext.FormMode == SPControlMode.Display)
         {
            try
            {
               using (SPSite oSPSite = new SPSite(SPContext.Current.Site.Url))
               {
                  using (SPWeb oSPWeb = oSPSite.OpenWeb())
                  {
                     String usersString = base.ListItemFieldValue.ToString();
                     SPFieldUserValueCollection userValueColl = new SPFieldUserValueCollection(oSPWeb, usersString);

                     int count = 0;
                     foreach (SPFieldUserValue userValue in userValueColl)
                     {
                        count++;
                        SPUser siteUser = userValue.User;
                        System.Diagnostics.Trace.TraceInformation("User found: {0}", siteUser.Name);

                        if (!string.IsNullOrEmpty(siteUser.Email))
                        {
                           string email = string.Format("mailto:{0}", siteUser.Email);
                           output.WriteBeginTag("a");
                           output.WriteAttribute("HREF", email);
                           output.Write(HtmlTextWriter.TagRightChar);
                           output.WriteEncodedText(siteUser.Name);
                           output.WriteEndTag("a");
                           if(count > 1)
                              output.WriteEncodedText(" , ");
                        }
                        else
                        {
                           output.WriteEncodedText(siteUser.Name);
                        }
                     }
                  }
               }
            }
            catch { }
         }
         else
         {
            base.Render(output);
         }
      }
   }
}

U can use this in your page layout in this way:

<%@ Register Tagprefix="Webcontrols" Namespace="Webcontrols" Assembly="Webcontrols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=868bd32625cae9fb" %>
Person: <WebControls:EnhancedUserField  FieldName="Person" runat="server"></WebControls:EnhancedUserField >
Categories: Sharepoint Tags:

Custom Sharepoint DateTimeField webcontrol with DateFormat property

September 18th, 2010 No comments

I was adding a Sharepoint datetime control to my page layout and I wanted to control the way the date was displayed. I found out that the Sharepoint control can’r do this. So I wrote a simple control for this. See source code below

using System;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;

namespace Webcontrols
{
   public class CustomDateTimeControl : DateTimeField
   {
      public string DateFormat { get; set; }

      protected override void Render(System.Web.UI.HtmlTextWriter output)
      {
         if (this.ItemContext.FormContext.FormMode == SPControlMode.Display)
         {
            if (!string.IsNullOrEmpty(DateFormat))
            {
               try
               {
                  DateTime selectedDate = (DateTime)base.ListItemFieldValue;
                  output.WriteEncodedText(selectedDate.ToString(DateFormat));
               }
               catch { }
            }
            else
            {
               base.Render(output);
            }
         }
         else
         {
            base.Render(output);
         }
      }
   }
}

U can use it in youre page layout like this:

<%@ Register Tagprefix="Webcontrols" Namespace="Webcontrols" Assembly="Webcontrols, Version=1.0.0.0, Culture=neutral, PublicKeyToken=868bd32625cae9fb" %>
Date: <WebControls:CustomDateTimeControl  FieldName="Date" DateFormat="dd MMMM yyyy" runat="server"></WebControls:CustomDateTimeControl>

In the control you can alter the text of the property DateFormat=”dd MMMM yyyy”
In this case dd MMMM yyyy causes the date to be renderd like: 18 september 2010

In this document there are some examples for the dateformat:

Date and Time Format Strings

Categories: Sharepoint Tags:

Getting a SPList object no matter what language of Sharepoint 2010

September 18th, 2010 Comments off

Today I was deploying a Sharepoint feature with a feature receiver that has a couple of commands that add pages to the pages list and added some reusable content to the reusable content list. When testing on my delopment environment everything worked fine. But when I started deploying on the testing environment the feature wouldn’t activate. I found the following problem:

I was creating a SPList object in this way:

using System;
using System.Runtime.InteropServices;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Utilities;

namespace Branding
{
	[Guid("6473e847-e8d5-4adf-b904-63029f32dceb")]
	public class BrandingEventReceiver : SPFeatureReceiver
	{
		private const string SiteTitle = "Custom site tiel";
		private const string MasterPageName = "/_catalogs/masterpage/Custom.master";

		public override void FeatureActivated(SPFeatureReceiverProperties properties)
		{
			SPSite site = properties.Feature.Parent as SPSite;
			{
				using (SPWeb web = site.RootWeb)
				{
					// set site Title
					site.RootWeb.Properties["Title"] = site.RootWeb.Title;
					site.RootWeb.Title = String.Format("{0}", SiteTitle);
					site.RootWeb.Properties["CustomMasterUrl"] = site.RootWeb.CustomMasterUrl;
					site.RootWeb.CustomMasterUrl = MasterPageName;
					site.RootWeb.Update();

					// disable show pages in navigation
					PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(site.RootWeb);
					publishingWeb.Navigation.CurrentIncludePages = false;

               // add reusable content
               SPList list = site.RootWeb.Lists[“Reusable Content”];
               SPListItem item = list.Items.Add();
               item["Title"] = "Information divider";
               item["AutomaticUpdate"] = "false";
               item["ReusableHtml"] = @"<h2 class=divider>Information</h2>";
               item.Update();

					// add custom content pages
               string pagesListName = SPUtility.GetLocalizedString("$Resources:cmscore,PagesListDisplayName", "cmscore", web.Language);
				}
			}
		}
   }

This is the line of code that causes the problem:

SPList list = site.RootWeb.Lists[“Reusable Content”];

Read more…

Categories: Sharepoint Tags: