Feeds:
Posts
Comments

Archive for the ‘Uncategorized’ Category

The problem

How do you add a custom control to your master page (or page layout) using the Design manager? In my first attempts I continuously got ‘Unknown server tag ‘uc1:FeedbackControl’

Quick introduction

Using the new way of creating and deploying your branding with the Design Manager needs some getting used to. The idea is:

  1. You start with a plain html page
  2. SharePoint automatically converts it to a master page (or layout page)
  3. You only edit the html page. SharePoint pushes your changes to the master page
  4. Most of the SharePoint controls and web parts can be configured and added by copy + pasting snippets into your html
  5. .NET server controls can also be placed on your page by using snippets.

In fact snippets is nothing more than a special kind of mark-up to put server controls in your html page.

But how to you add a custom control?
I created my branding with the Design Manager. I also have a Visual Studio 2012 solution with custom web parts and custom user controls.
After deploying the Visual Studio solution to my server I tried to add some of my custom user controls to the master page.  All attempts I made resulted in “Unknown server tag”

Defining your control.
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>-->
Putting your control on your page.
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl" />-->
<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->

The solution

The trick is easy. Instead of registering your control on top of the html together with all the default SharePoint controls. You need to put the @Register statement and your code together

<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>-->
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl" />-->
<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->

So you do NOT place the @Register-statement before the DOCTYPE declaration. Embed it directly into your html page together with your snippet.

One other tip.

I had some problems / errors with defining multiple controls with the same tag prefix. If you have multiple controls on a page give them all a different TagPrefix and you will be fine.

<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/FeedbackControl.ascx" TagPrefix="uc1" TagName="FeedbackControl" %>-->
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/Notification.ascx" TagPrefix="uc2" TagName="Notification" %>-->
<!--SPM:<%@ Register Src="~/_controltemplates/15/AmToPm.Client.Intranet/DisplayStatus.ascx" TagPrefix="uc3" TagName="DisplayStatus" %>-->
<!--CS: Start Create Snippets From Custom ASP.NET Markup Snippet-->
<!--SPM:<uc1:FeedbackControl runat="server" id="FeedbackControl1" />-->
<!--SPM:<uc2:Notification runat="server" id="Notification1" />-->
<!--SPM:<uc3:DisplayStatus runat="server" id="DisplayStatus1" />-->
<!--CE: End Create Snippets From Custom ASP.NET Markup Snippet-->

 

Read Full Post »

I use the Visual Studio CKSDEV plugin so much that I almost forgot it’s not standard Visual Studio functionality. It’s no doubt the number one tool when creating SharePoint solutions with Visual Studio.

Unfortunately the plugin is not yet updated for Visual Studio 2012 / SharePoint 2013.  But the people at Mavention have created a small tool that mimics the “Copy to GAC” functionality. So it takes at least some of the pain away.

Read all the details on Weldak’s blog:
http://blog.mastykarz.nl/quickly-deploying-sharepoint-2013-projects-mavention-quick-deploy/

Download the tool here:
Mavention Quick Deploy

Update:
As Gary pointed out in the comments below. There is a new kid in town called Fishbone. The reviews, functionality and screenshots look promising. Let’s find out!
http://visualstudiogallery.msdn.microsoft.com/4784e790-32f4-455f-9228-53f537c03787

Read Full Post »

Introduction

If you ever had to implement some kind of visual change in SharePoint, you know that, with previous SharePoint versions, this could be a challenge. Even SharePoint 2010 is spitting out HTML that makes website designers cry.

I installed SharePoint 2013 Foundation Preview this week. And I decided to take a look at the changes in HTML with some of my past branding projects in mind

Notice: Although I’ve implemented quite a few custom look and feels in SharePoint. I do not consider myself an expert in CSS, HTML 5 or SEO. But I do recognize bad HTML code. ;-)

<head>

First thing you notice is that the <head> section is much cleaner. It is better aligned, I only counted 2 JavaScript script blocks. All the other JavaScript code is nicely stored in external JavaScript files and (dynamically) referenced on the page.

There seems to be a lot of this dynamic registering of JavaScript files going on ( RegisterSodDep ). These JavaScript files only load when they are requested. This significantly reduces the load time of a web page. This function was also available in SP2010 but to my knowledge it was not used this much.

I’m also missing some hidden input fields. I’m not sure if this is by design or if it’s due to my freshly installed SharePoint and my lack of enabled features.

The _layouts/15/

They have added an extra version number in the /_layouts path.
Examples:

<img src="/_layouts/15/images/spcommon.png" />
<link rel="stylesheet" type="text/css" href="/_layouts/15/1033/styles/Themable/corev15.css"/>
<script type="text/javascript" src="/_layouts/15/init.js"></script>

A good move as it will probably make future backward compatibility easier to maintain.

Web parts

In previous SharePoint versions, adding web parts to your page results in nested <table> elements embedded in the page. Styling these nested tables is a handful. Luckily the tables made way for <div> elements.

One word of warning though. The web part title and body are still wrapped in 4 levels of divs. IMHO They could have simplified it even further.

Another example is that the HTML of the web part title is rather complex.

<div>
  <span>
    <h1>
    <nobr>
      <span>A web part title</span>
    </nobr>
    </h1>
  </span>
</div>.

Personally I see no reason for this complex HTML structure. Except maybe for some compatibility issues with some older browsers?

The body

No funky load scripts anymore on the body element. They are still there though. They are probably replaced with jQuery alternatives. For example the “#s4-workspace” style attribute is still updated dynamically with each screen resize.

The HTML in the body is cleaner. SP2013 clearly steps away from the table layout which is a good thing. I did notice some <div> elements with css classes like ms-table and ms-tablecell. ;-)

The deep nesting of HTML elements is still present in SharePoint 2013. Probably due to the extreme flexibility that SharePoint offers to modify and extend almost everything that is on your page.

Conclusion

In general the SharePoint 2013 HTML code makes a big leap forward. The nested <table> elements that were over present in older versions of SharePoint are gone.

Huge clean-up in the head section, controls are rewritten to use HTML best practice guidelines (example <ul> instead of <tables>) .

Yes there is still some optimisation possible but overall designers will have it a lot easier when applying a corporate identity on SharePoint site.

Read Full Post »

Introduction

This topic might seem basic but I get the question quite often. How do you read logs?

Reading the log file.

The simplest way is opening the log files from the 14$\logs in Notepad. This might be quickest way but not the most efficient in a live multiuser environment. I usually use this in a development environment in combination with a text editor that automatically reloads the file when it’s updated (Notepad++).

Using powershell with a correlation id

You can use powershell to quickly track down a correlation ID and dump the related log files into a file

get-splogevent -starttime (get-date).addminutes(-20) | where-object { $_.correlation -eq “b66db71a-3257-4470-adf9-5c01dc59ecb3″ } | fl message > c:\errors.txt

More info can be found here :
http://www.mysharepointadventures.com/2011/08/175/

Uls viewer

A Windows application for viewing the ULS logs more easily. Very handy when you are (trying to) reproduce a specific error and during debugging
I use it when I’m trying to track down a specific error and during debugging.

http://ulsviewer.codeplex.com/

Farm solution

Codeplex also has a nice solution which you can query the SharePoint logs with from within Central Administration.
The solution installs in your Central Administration. Very handy if you want a quick look in your logs files without having to connect over remote desktop to the actual server.
For detailed log digging this tool might not be sufficient.

http://sp2010getcorrelation.codeplex.com/

Read Full Post »

Introduction

This article explains how to manage the layout of your site pages (= wiki pages) with the standard SharePoint 2010 Foundation functionality .
Default SharePoint pages are stored in a “Site Pages” library which is basically a wiki page library.

This article assumes you know how to create SharePoint 2010 projects in Visual Studio 2010 and how to deploy them.

The issue

The layout of your Site Pages is controlled by the “Text Layout” button in the ribbon control. SharePoint 2010 has a few default layouts defined. But there is no way to extend this functionality like you can with page layouts and the publishing feature.
A customer wanted to have the 2 column layout by default when creating a new page. He also wanted to have a logo and some web parts on the page as well.

The solution.. huh hack?

What the “Text Layout” button does is simply saving some HTML code into a property of the page. We can do this ourselves every time a new page is created by I adding an event receiver to the wiki library.

Open your SharePoint 2010 project.

Add resource file

  • Add a resource file to your project.
    This is needed to contain the actual HTML that will define your layout.
  • Here is my resource file with the HTML.
  • The HTML I used in the above screenshot is
    </pre>
    <div class="ExternalClass1E4D6ECE06C64E0C84066BDC723BF78D">
    <table id="layoutsTable" style="width: 100%;">
    <tbody>
    <tr style="vertical-align: top;">
    <td style="width: 66.6%;"></td>
    <td style="width: 33.3%;">
    <div class="ms-rte-layoutszone-outer" style="width: 100%;">
    <div class="ms-rte-layoutszone-inner">
    <div style="text-align: right;"><img src="/_layouts/images/AmToPm.SharePoint/logo.png" alt="logo" border="0" /></div>
    </div>
    </div></td>
    </tr>
    </tbody>
    </table>
    <span id="layoutsData" style="display: none;">false,false,2</span></div>
    <pre>
    

Add an Event receiver

  • Right click on your project and an event receiver
  • Click add. In the next page make sure to select the Wikipage library and “item added”
  • You now have your event handler. It will trigger every time a new wiki page is added to a wiki page library.
  • Add the following code to your event receiver
    ///
    <summary> /// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    {
       base.ItemAdded(properties);
    
       // TODO: if needed do some checks here
    
       try
       {
    	   SPListItem item = properties.ListItem;
    
    	   this.EventFiringEnabled = false;
    	   item[SPBuiltInFieldId.WikiField] = ResourceFile.Wiki2ColumnMarkup;
    	   item.SystemUpdate(false);
    	   this.EventFiringEnabled = true;
       }
       catch (Exception ex)
       {
    	   Log.ErrorException("Updating the wikipage layout failed.", ex);
       }
    }
    

Make sure to disable the event firing before you update your page.

Read Full Post »

When creating event receivers or workflows it might be interesting to look at the differences between the following SPListItem methods. The differences might be subtle but it can make a huge difference when you have extra event receivers or workflows attached to your SharePoint list or items.

Update()

  • Updates the item in the database.
  • Updates the “Modified” and “Modified by” values.
  • Creates a new version

Systemupdate()

  • Updates the item in the database.
  • No changes in the “Modified” and “Modified By” fields.
  • No new version.
  • Triggers the item events.

Systemupdate(true)

  • Same as Systemupdate() and increments the item version.
  • Using SystemUpdate(false) is exactly the same as SystemUpdate()

UpdateOverwriteVersion()

  • Updates the item but does not create a new version.
  • Updates the “Modified” and “Modified by” values.

Note that :
You can also disable the triggering of events by using “this.EventFiringEnabled = false;”. Do your update and enable the events again with “this.EventFiringEnabled = true;”

Hope it helps,
W0ut

Read Full Post »

Quick description

Application Tool Manager (APM) is a great utility when programming for SharePoint 2010 (and general (IIS) web development) . Very handy if you want to attach your debugger to a specific w3wp.exe Process ID (PID)

The description on their website

This freeware application is a System Tray utility for providing quick access to common IIS tasks which are useful on a SharePoint development box. It may also be useful to others working with IIS. In essence, it enumerates the app pools on your box and lets you right click ‘em to bounce ‘em!

You can download the tool here<: http://www.harbar.net/articles/apm.aspx

 

Read Full Post »

We often get Excel files with content to import into SharePoint. Most of the time I fire up Visual Studio and write a small console application to import the Excel data. However with SharePoint 2010 I got the error “The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine”.

The idea

When I need to import content into SharePoint using the oledb data is far the easiest way to read Excel files without having to install office on your SharePoint server.

You simply add an OleDbConnection , an OleDbCommand, an OleDbDataAdapter and a correctly formulated select statement.

            string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Import\Sample.xslx; Extended Properties=""Excel 8.0;HDR=Yes"";";
            string CommandText = "SELECT * FROM [Services$]";

            OleDbConnection connection = new OleDbConnection(ConnectionString);
            OleDbCommand command = new OleDbCommand(CommandText, connection);
            connection.Open();

            OleDbDataAdapter adapter = new OleDbDataAdapter(command);

            DataSet dataset = new DataSet();
            adapter.Fill(dataset, "Excel");

The cause

SharePoint 2010 is 64 bit so you need to compile your custom SharePoint code as a 64-bit applications. However the default Jet Library does not support 64-bit applications and thus results in the following error:

The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine.

Solution

Luckily Micosoft has released a solution in the form of the Microsoft Access Database Engine 2010 Redistributable

  1. Download the Microsoft Access Database Engine 2010 Redistributable
  2. Install the package on your development machine
  3. Modify your OleDb Connection string from:
    Provider=Microsoft.Jet.OLEDB.4.0; ….
    to
    Provider=Microsoft.ACE.OLEDB.12.0;….
  4. rebuild your application
    note
    : make sure your application is set to compile as a 64 bit application

Don’t forget to install this redistibutable on your SharePoint server as well.

Read Full Post »

To format data in SharePoint I often use xslt. The default formatting of dates however is pretty useless

<xsl:value-of select="@YourDateParam"/>

Results in : 2009-03-23 00:00:00

 

You can also use a predefined locale like this:

<xsl:value-of select="ddwrt:FormatDate(@YourDateParam, 1033, 15)"/>

Results in : Thursay, August 24, 2011 09:00:00 PM

 

If your required date time format is not available, you can also define a custom date time formatting.

<xsl:value-of select="ddwrt:FormatDateTime(string(@YourDateParam) ,1033 ,'dd-MMM-yyyy')" />

Results in : 22-03-2011

<xsl:value-of select="ddwrt:FormatDateTime(string(@YourDateParam) ,1033 ,'dd/MMM/yyyy')" />

Results in: 22/Sep/2011

Other formats

Output Locale Format
3/23/2009 1033 1
3/23/2009 12:00 AM 1033 2
Monday, March 23 2009 1033 3
12:00 AM 1033 4
Monday, March 23, 2009 12:00 AM 1033 7
3/23/2009 12:00:00 AM 1033 13
Monday, March 23, 2009 12:00:00 AM 1033 15
23/03/2009 2057 1
3/23/2009 12:00 AM 2057 2
23 March 2009 2057 3
00:00 2057 4
23/03/2009 00:00 2057 5
23 March 2009 00:00 2057 7
00:00:00 2057 12
23/03/2009 00:00:00 2057 13
23 March 2009 00:00:00 2057 15

Read Full Post »

Christophe Geers has a great article about how to setup a build server with Jetbrains TeamCity.

Read his article here:
http://cgeers.com/2011/05/28/running-unit-tests-with-teamcity/

I ‘m planning on integrating a build server in my Media Center. I was still reading up on all the different products and technologies available. After reading Christophe’s article I might go for the TeamCity as well.

Regards,

Read Full Post »

Older Posts »

Follow

Get every new post delivered to your Inbox.