Wednesday, September 25, 2013

SharePoint XSLT and Hyperlink

Content Query webpart is like a swiss army knife for developers who have the task to display various SharePoint content like lists, libraries and media on any page. And XSLT is the design language you will have to use to customize the UI and layout of the content displayed within the Content Query web part.

This post details about how to pull a Hyperlink column from a link and display on the page.

Create a new variable

<xsl:variable name="DownloadLink">
          <xsl:call-template name="OuterTemplate.GetTitle">
            <xsl:with-param name="Title" select="@Url"/>
          </xsl:call-template>
</xsl:variable>

Note: @Url is the the actual name of the  Hyperlink column in the list.


Display the link


<div class="dLink">
    <a href="{substring-before($DownloadLink,',')}">
    <xsl:value-of select="substring-after($DownloadLink,', ')" />
    </a>
</div>

That's it!

Save your changes and look for the Hyperlink column on the page in your Content Query web part.

Tuesday, April 19, 2011

Delete all table in a Database

EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

Deletes all tables and this operation can also be rolled back!!

Thursday, March 10, 2011

Authenticate external users to Sharepoint 2010.

Here is an article briefing the way to create a custom Trusted Identity Provider using the new Windows Identity Framework in Sharepoint 2010.

http://stefvanhooijdonk.com/2010/08/19/writing-your-own-trusted-identity-provider-for-sp2010-1/

Using this provider, external users like Users in a Sql Server, Facebook or any source will be able to login to Sharepoint 2010 and not just AD users. Cool!

Wednesday, March 2, 2011

Events in Sharepoint 2010

Here are the events available in Sharepoint 2010 which gives developers better control when things are happening/about to happen in the site.

Items in green are new to Sharepoint 2010 and are Asynchronous events.

Site Events
  • SiteDeleting/SiteDeleted
  • WebDeleting/WebDeleted
  • WebMoving/WebMoved
  • WebAdding/WebProvisioned

List Events
  • EmailReceived
  • FieldAdding/FieldAdded
  • FieldUpdating/FieldUpdated
  • FieldDeleting/FieldDeleted
  • ListAdding/ListAdded
  • ListDeleting/ListDeleted

Item Events
  • ContextEvent
  • ItemAdding/ItemAdded
  • ItemUpdating/ItemUpdated
  • ItemDeleting/ItemDeleted
  • ItemCheckingIn/ItemCheckedIn
  • ItemCheckingOut/ItemCheckedOut
  • ItemUncheckingOut/ItemUncheckedOut
  • ItemAttachmentAdding/ItemAttachmentAdded
  • ItemAttachmentDeleting/ItemAttachmentDeleted
  • ItemFileMoving/ItemFileMoved
  • ItemFileConverted

Workflow Events
  • WorkflowStarting/WorkflowStarted
  • WorkflowPostponed
  • WorkflowCompleted

Saturday, February 12, 2011

Deploy UserControl to Sharepoint



Here are the steps to deploy.
1. Create a WSPBuilder Project in Visual Studio 2008

2. Add folders to the Project which looks similar to the 12 hive. Put your UserControl (.ascx file) in the ControlTemplates of the 12 hive.


Here, TestUC is the UserControl and is added to the ControlTemplates folder I created. I idea behind this is, once this is deployed, as per the folder structure, the TestUC will be deployed to the ControlTemplates folder in the 12 hive.

Also add the elements.xml and the features.xml to the folder (name of the feature, in this case it is DeployUC)

3. Probably the most important of the steps. Open elements.xml and add the UserControl element to the elements.

3. Create a Code folder and add the TestUC.ascx.cs file. We will link the UserControl to its code file using the Inherits property for the UserControl.


4. Open TestUC.ascx and link the Test.ascx.cs file

If you see, DeployUC.Code is the Namespace under DeployUC assembly under which TestUC (the code-behind file for the UserControl) resides. One this feature is deployed, this assembly sits in GAC and can always be found by the TestUC UserControl.

5. Build and deploy the package and this UserControl is now available for use on to any page.

6. Done.

Post your comments and questions if you have any.

Tuesday, February 8, 2011

GUID

Is GUID unique? While each generated GUID is not guaranteed to be unique, the total number of unique keys (2^128 or 3.4×10^38) is so large that the probability of the same number being generated twice is very small.

GUID is a 16 byte (or 128 bits) combination of alphabets and numerics. Once you take it apart, the bits of the GUID break down like this:
  • 60 bits of timestamp,
  • 48 bits of computer identifier,
  • 14 bits of uniquifier, and
  • 6 bits are fixed,

for a total of 128 bits.

More information can be found here.