vrijdag 16 november 2012

Images from picture library not displayed in IE

Today I discovered a strange behavior in Internet Explorer. I  uploaded some images to my image library and I referred to them in my custom aspx page. All the images displayed correctly except one. In Firefox everything rendered correctly, in IE only the thumbnail and the web image was available. The full image was not available and I received a red cross on my page.

Conclusion: the image was corrupt!

donderdag 15 november 2012

How to use SharePoint’s default modal popup from code behind?

A while ago I needed to create a shopping basket. When you click on an item in that basket it would be nice if that item opens in a modal popup. But how can you access the default SharePoint modal popup dialog if it isn’t in your masterpage?

I used following code:

public static class Helper
{
    public static string GetDialogURL(string url, bool refreshOnClose, double width, double height)
    {
        string str = string.Concat(new object[]
		{
            "SP.UI.ModalDialog.showModalDialog({ url:'",
			url,
			"',tite: 'Move Documents',allowMaximize: true ,showClose: true,width:",
			width,
			",height:",
			height
		});
        if (refreshOnClose)
        {
            str += ",dialogReturnValueCallback: function(dialogResult){SP.UI.ModalDialog.RefreshPage(dialogResult)}";
        }
        str += "});";
        return str;
    }
    public static string GetDialogURL(string url)
    {
        return Helper.GetDialogURL(url, true, 700.0, 800.0);
    }
}

maandag 12 november 2012

XSL template to obtain all visible fields in Content Query WebPart

When we are editing XSLT for Content Query WebPart, XSLTListViewWebPart or any other WebPart with configurable XSLT, you can obtain all list fields and their values with following template:
<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
      <xsl:call-template name="OuterTemplate.GetSafeLink">
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="DisplayTitle">
      <xsl:call-template name="OuterTemplate.GetTitle">
        <xsl:with-param name="Title" select="@Title"/>
        <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
      </xsl:call-template>
    </xsl:variable>
    <b>
      Item: <i>
        <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
          <xsl:value-of select="$DisplayTitle"/>
        </a>
      </i>:
    </b>
    <ol>
      <xsl:for-each select="@*">
        <xsl:sort select="name()"/>
        <li>
          <xsl:value-of select="name()" />
          <xsl:text disable-output-escaping="yes"> </xsl:text>
          <i>
            <xsl:value-of select="."/>
          </i>
        </li>
      </xsl:for-each>
    </ol>
    <br />
  </xsl:template>

Notice that @ is the beginning char of any list field.

woensdag 7 november 2012

SharePoint 2010 Search Center MasterPage with navigation

It’s hard to navigate from a Search Center, so I decided to modify the minimal masterpage to allow you to show the topnavigation of the page. It will also show the site icon and breadcrumb navigation just like the v4.master does.

Minimal masterpage with navigation