Sladescross's Blog

Blogging about Sharepoint related stuff

Aspiring Architect: Deploying Custom Master Page Using a sharepoint Feature August 30, 2013

Filed under: Custom,Custom Master Page,Deploy,Feature,Master Page,Sharepoint Designer — sladescross @ 11:46 am


Azure Custom Virtual Machine January 8, 2013

Filed under: Azure,Certificate,Create,Custom,Image,Virtual Machine — sladescross @ 4:43 pm

You can create a custom virtual machine by providing advanced options, such as size, connected resources, DNS name, and network connection. You must use this option if you want to connect virtual machines or if you want to use a custom image to create the machine.

Before you create a virtual machine, you should decide how it will be used. If you have a need for only one virtual machine in your application, you choose to create a stand-alone virtual machine. If you need multiple virtual machines in the same cloud service that can communicate with each other and act as a load-balanced application, you choose to connect the new virtual machine to an existing virtual machine.

This is GUI based not PowerShell.

Windows Azure IaaS – Upload a custom built VM template.

The steps in summary are as follows:

1-      Create your VM using Windows 2008 Hyper-v Manager

2-      Prepare your VM to be used as a template (Generalize the VM aka sysprep)

3-      Create and register a management certificate to be used to connect remotely to your Azure subscription

4-      Connect and upload your VM to windows Azure

Third: Create and register a management certificate to be used to connect remotely to your Azure subscription

In order to be able to manage your Windows Azure subscription in general and more specifically any administration work that will require you to communicate with windows Azure remotely you will need to use a certificate installed on the machines you are using for the communication. That certificate should be added to your management certificate in your Windows Azure settings so it trusts the machines you will use to manage your account.

The management certificates enable client access to Windows Azure resources when using the Windows Azure SDK tools, the Windows Azure Tools for Microsoft Visual Studio, or the Windows Azure Service Management REST API. You can add as many as 25 management certificates to a subscription.

In our case (later in this article) you will see that we will use the Windows Azure ASK tools to upload the created VM Image.

Here are the steps to do that:

  1. Create a new certificate as follows:
  2. Open command prompt with elevated privileges
  3. Execute the following command:
  4. makecert -sky exchange -r -n “CN=<CertificateName>” -pe -a sha1 -len 2048 -ss My “<CertificateName>.cer”

Custom SharePoint Field June 5, 2012

Filed under: Custom,Custom SharePoint Field Type,Field Type — sladescross @ 1:49 pm

A custom field type consists of many different parts. The hub of the custom field is the field type class. If the custom field needs to store data in a more complex way than For example.e. a string or a number, this class will contain a reference to a field value class. If the custom field offers a custom presentation, then this class will also contain a reference to a field control class. In this field control class you can choose to dynamically build your controls in code or refer to a RenderTemplate defined in a user control.

When your custom field is all laid out it can be compiled into a dllan assembly. To inform SharePoint about the existence of your custom control and its structure you have to create a field definition file that needs to be deployed to the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML directory of SharePoint. This definition file contains CAML markup containing a reference to the assembly and the field type class.



Custom New Document Link May 30, 2012

Filed under: Custom,Link,New,New Document,Template — sladescross @ 11:33 am

Where XXXX is the JavaScript I copied from the toolbar. So, my full HTML looked like:

 Create new Mod Prop

I save this, and set my content editor web part to have no chrome (no title or anything). Presto, done! I would point out that updating the template could mean updating the JavaScript in the content editor. Still, not a bad effort!


Document Set Custom Form May 28, 2012

Filed under: Custom,Document Sets — sladescross @ 2:57 pm

Add a document set custom (layout) form.


SharePoint Search Custom Controls May 14, 2012

Filed under: Custom,Search Custom Web Part — sladescross @ 2:03 pm

Although the out-of-the-box search Web parts provided by Microsoft Office SharePoint Server (MOSS) 2007 are very customizable, there are situations where you may want to develop your search interface to hook into MOSS. This download consists of a Search Box user control and a Search Results user control. The Search Results user control uses the new FullTextSqlQuery API to return the search results. As user controls (I might add a Web part version later), the look and feel are very easy to customize.

The following is the complete sample code for the Custom Keyword Search Web Part, described in Walkthrough: Creating a Basic Search Web Part Using the Query Object Model.

To find out how to do this, I opened up trusty old .NET Reflector and tried to figure out how the sorting in the OOB CoreResultsWebPart works so I could override it to sort on some other column. I found that the CoreResultsWebPart uses a datasource. This datasource is of the type CoreResultsDatasource in the namespace Microsoft.Office.Server.Search.WebControls and it represents the data source control used to retrieve the search results for the Core Search Results Web Part (according to MSDN). This class contains all kinds of interesting properties, including the (largely undocumented) SortOrder property. The SortOrder property has the type Microsoft.Office.Server.Search.Query.SortCollection. I figured out that by adding my own managed properties to the collection the search results are ordered by that property.

Next I wanted to know where this datasource is configured in the reflectored code. It turns out that the CoreResultsWebPart has a ConfigureDataSourceProperties method in which the datasource is configured. So all I need to do is override that method and put my own code for sorting the datasource in there.


Custom Expiration Policy May 10, 2012

Filed under: Custom,Expiration Policy — sladescross @ 5:42 pm

The purpose of the article is to demonstrate the use of a custom expiration policy associated to a SharePoint Content Type. The custom Expiration Policy can be used to invoke custom business logic at the time of expiration.



Custom Controls and Custom Application Pages July 26, 2011

Custom controls for Sharepoint 2007.

To create a custom Control:

  • Create a Class Library project
  • Inherit from WebControl class in System.Web.UI.WebControls namespace or
    Control class in System.Web.UI namespace
  • Override the “Render” or “RenderContents” method

To use the custom Web Control:

  • Put the custom control assembly in Bin directory of Web application (GAC may
    also be used)
  • Mark it as a safe control in web.config
  • Open master page or a page layout file
  • Register the control using Register directive and assign a TagPrefix
  • Use the control using the TagPrefix and Class name

  • Add a folder under the LAYOUTS folder called “ASPX”.
  • Right click on the ASPX folder, Add new item, Select Text File.
  • Rename the TextFile1.txt to “CustomPage.aspx”

Step 3 – Create the code behind folder and

  1. Add a folder called “Assembly” under the project menu.
  2. Add a folder under the Assembly folder called “WebControls”.
  3. Right click on the WebControls folder, Add new item, Select Class.
  4. Rename Class1.cs to Control1.cs
  5. Right click on the WebControls folder, Add new item, Select Class.
  6. Rename Class1.cs to Control2.cs

Step 4: Add a Reference to

  1. On the Project menu, click Add Reference.
  2. On the .NET tab, click System.Web.
  • Associates aliases with namespaces and class names.
    <%@ Register TagPrefix=”CustomControls”
    Namespace=”Your Namespace Name” Assembly=”Your Assembly Name, Version=,
    Culture=neutral, PublicKeyToken=You Public Key Token” %>
  • Add the Control Place Holder.
  • Add the Custom Controls to the Control Place Holder.
    <asp:Content ID=”Main” runat=”server”
    <CustomControls:Control1 ID=”control1″
    <CustomControls:Control2 ID=”control2″

Step 6: Create The Image Control

  1. Open the Control1.cs file.
  2. Add the following using statements:
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
  • 3. Override the CreateChildControls method with this code:protected override void
    Image imgButton =
    imgButton.ImageUrl = “/_layouts/images/eggheadcafe/eggheadcafe.jpg”;
    imgButton.ToolTip = “eggheadcafe”;
    imgButton.Attributes.Add(“OnClick”, “location.href(‘;)”);
    imgButton.Attributes.Add(“style”, “cursor: hand;”);

Label rss = new Label();
rss.Text = sb.ToString();

I would like to guide you through a process of creating a simple yet powerful custom WebControl. At the end of this post you should be able to use the example we will build here and extend it with new functionality to make it fit to your needs.

SPPropertyBag with custom administration page.

Dynamically set page title.

ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)Page.Master.FindControl(“PlaceHolderPageTitle”);
LiteralControl control = new LiteralControl();
control.Text = “New title”;


MySite Customisation May 31, 2010

Filed under: Custom,Customisation,MySite — sladescross @ 8:54 am


Sharepoint Custom Javascript April 26, 2010

Filed under: Custom,Javascript,Sharepoint — sladescross @ 8:49 pm

SharePoint ScriptLink control (< SharePoint:Link />)

function getTagFromIdentifierAndTitle(tagName, identifier, title) {

  var len = identifier.length;

  var tags = document.getElementsByTagName(tagName);

  for (var i=0; i < tags.length; i++) {

    var tempString = tags[i].id;

    if (tags[i].title == title && (identifier == “” || tempString.indexOf(identifier) == tempString.length – len)) {

      return tags[i];



  return null;



Use content editor web part.

Add web parts to content pages.


Append ?Contents=1 to the webpart page’s URL to display the Webpart Maintenance Page



Get every new post delivered to your Inbox.

Join 63 other followers