Webcast Series for ASP.NET Developers Who Want to Learn SharePoint

[via Paul Andrew]

[Microsoft is] doing lots of things around introductory SharePoint development for .NET developers over the next few months. Here is the schedule for a series of MSDN web casts on 10 introductory SharePoint development topics for .NET developers. If you are a .NET developer then chances are these are the most interesting ten introductory things you can do on SharePoint Products and Technologies.

http://blogs.msdn.com/pandrew/archive/2008/05/12/sharepoint-developer-msdn-web-cast-series.aspx

Technorati Tags: []

Piping STSADM command

I recently discovered that piping can be used in conjunction with STSADM command. I always found it difficult to use that command. It has too many options and parameters that are not always obvious and often very difficult to use. Piping makes it easier to use STSADM command, it can be used for search through STSADM keywords in the commands: For example, stsadm | find "enum" can be used to find all STSADM keywords related to enumeration within SharePoint. Or, you can also use pipe | more to paginate the STSADM output, which could be very useful.

You can also redirect STSADM output using the redirecting command: stsadm > filename >& This can be very helpful when you need to generate an output and view it later, or if you need to export that output into a different application.

I realize it's very basic, but it's the basic things like this that help me save time and keep my sanity.

Attaching old Content Database to new Web Application in MOSS 2007 or WSS 3.0

If you have recently re-attached your content database to the new web application in SharePoint 2007 (whether because you have moved your SharePoint install or simply because you had to re-create the web application on your current server), you might have noticed a new error (Event ID: 5555; Event Source: Office SharePoint Server) occurring hourly in the Event Log of your web-front SharePoint server.

The description of the error tells you to run stsadm – o preparetomove, which doesn't seem to fix the problem, unfortunately. This command only prevents the error 5555, if you run it before moving and re-attaching your content databases. To fix error 5555, you need to run stsadm –o sync instead.

In my case, running the following command made error 5555 disappear:

stsadm -o sync -DeleteOldDatabases 0

As usual: ALWAYS BACKUP YOUR SHAREPOINT BEFORE MAKING ANY CHANGES TO ITS CONFIGURATION

Getting around the limitation on a number of controls on SharePoint page

Apparently there is a limit on a number of controls you can have on a SharePoint page. By default, no more than 200 controls are allowed on the SharePoint page. Not sure, why this limitation is there, but it is. To get around this problem, you need to increase the MaxControls setting in your web.config file:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

<PageParserPaths>

</PageParserPaths>

</SafeMode>

In my case, I have MaxControls parameter set to 300.

SharePoint public-facing website and Microsoft Office documents

When you have a public-facing site built using SharePoint technologies, opening Microsoft Office documents (Word, Excel, PowerPoint, Visio, etc.) stored on this website requires user to login. You can hit Cancel at the login prompt and still be able to see the document, but having a login prompt displayed to the Internet users, sort of defeats the purpose of having SharePoint-built public facing website with anonymous access turned on. This happens becuase Microsoft Office is closely integrated with MOSS or WSS 3.0 now, and MS Office is now able to recognize that the document is stored within SharePoint, so the appropriate SharePoint authentication/authorization tools kick in. This problem can be resolved mostly by implementing two simple steps (assuming you have already enabled anonymous access on SharePoint):

  1. Disable 'Client Integration' for the web application under Central Admin Home Page >> Application Management >> Authentication Providers
  2. Remove the OPTIONS verb from the <HTTPHandlers> registration line in web.config file


Related resources:

Enabling anonymous access on MOSS 2007 / WSS 3.0 web applications

To enable anonymous access for a web application within SharePoint:

1. Go to Central Administration >> Application Management >> Authentication Providers.

  • make sure to pick correct web application from the drop-down list at the top-right corner of the page.
  • select the Membership Provider (most likely it will be "Default") and enable check "Enable anonymous access" checkbox.
  • click OK to save the settings.

2. The step above will usually enable anonymous access in IIS Manager, but just be sure:

  • open IIS Manager
  • right-click on your website and click on "Edit" under Authentication and Access Control
  • make sure "Enable anonymous access" is checked

3. We now need to explicitly enable anonymous access on our website(s)

  • browse to the website
  • click Site Actions >> Site Settings >> People and Groups >> Site Permissions
  • click on Settings >Anonymous Access and enable anonymous access for the site

* Anonymous access will be also enabled on all subsites that inherit security settings from the parent site.



Related resources:

SharePoint Designer Bug With Creating Data View Web Parts

For those who has been getting the ultimate crashes from SharePoint Designer, and many weird oddities with it, this is something that you should know while working with Data View Web Parts. Occasionally, SharePoint Designer will NOT allow you to add a Data View Web Part no matter what you do, as shown below, and the main reason is... *drum roll*... your file is not saved.

The first screen shot shows a "changed but not saved file" and "Insert Selected Fields As..." not working and the second screen shot shows the "Insert Selected Fields as..." working after saving.

SharePoint Tip: Displaying HTML Encodes Properly

Here's a tip for those people getting &amp; instead of & (and all those other fancy html encodes) from your XSLT variables. You just need to add disable-output-escaping and set that to "yes" when you do a value-of.

<xsl:value-of select="$Site" disable-output-escaping="yes"/>

String Replacement with XSLT

While working with SharePoint, I found that I sometimes need to replace strings with some characters or strings, for example, replacing "&amp;" with "&", or replacing "_x0020_" with " ". This is a useful template to do so. I got this template from here.

   1:      <!-- here is the template that does the replacement -->
   2:      <xsl:template name="replaceCharsInString">
   3:        <xsl:param name="stringIn"/>
   4:        <xsl:param name="charsIn"/>
   5:        <xsl:param name="charsOut"/>
   6:        <xsl:choose>
   7:          <xsl:when test="contains($stringIn,$charsIn)">
   8:            <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
   9:            <xsl:call-template name="replaceCharsInString">
  10:              <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/>
  11:              <xsl:with-param name="charsIn" select="$charsIn"/>
  12:              <xsl:with-param name="charsOut" select="$charsOut"/>
  13:            </xsl:call-template>
  14:          </xsl:when>
  15:          <xsl:otherwise>
  16:            <xsl:value-of select="$stringIn"/>
  17:          </xsl:otherwise>
  18:        </xsl:choose>
  19:      </xsl:template>

And here's how you'll call it.

   1:  <!-- pretend this is in a template -->
   2:    <xsl:variable name="myString" select="'This%20is%20Test'"/>
   3:    <xsl:variable name="myNewString">
   4:      <xsl:call-template name="replaceCharsInString">
   5:        <xsl:with-param name="stringIn" select="string($myString)"/>
   6:        <xsl:with-param name="charsIn" select="'%20'"/>
   7:        <xsl:with-param name="charsOut" select="' '"/>
   8:      </xsl:call-template>
   9:    </xsl:variable>
  10:    <!-- $myNewString is a result tree fragment, which should be OK. -->
  11:    <!-- If you really need a string object, do this: -->
  12:    <xsl:variable name="myNewRealString" select="string($myNewString)"/>

And there you have it. Very useful indeed.

Missing Timer job definitions after SharePoint move

If you have recently moved your SharePoint site (WSS 3.0 or MOSS 2007) from one hardware to another using backup/restore procedure, you might have noticed a few missing timer jobs definitions: Scheduled Approval, Scheduled Page Review, Scheduled Unpublish, Variations Propagate Page Job Definition, and Variations Propagate Site Job Definition. In our case, we had multilingual SharePoint site that stopped propagating variations after SharePoint move, so the content created in one language was not re-created in another. Very frustrating…

After looking into the problem, I discovered that SharePoint does not restore those timer job definitions by default. Naturally, not having those jobs will cause problems with scheduled publishing as well as variations propagation. To get those timer job definitions back on the list and running again, you will have cheat a little by creating a new site collection using Publishing Portal or Collaboration Portal templates. Creating new site collection using Publishing Portal or Collaboration Portal templates will force SharePoint to create missing timer job definitions. New site collection can be removed shortly after created.

Note: Changes made in variations since the SharePoint move might take while to propagate. To expedite the propagation you can manually force the variations update.