Archive for March, 2012

JQuery in ASP.NET Applications – My jDiv Solution

So, I have a general frustration with working with jQuery in an ASP.NET application. The first, and most obvious, is the ugly markup the HTML controls output. The muddled IDs and the inability to add custom HTML attributes is frustrating.

So, I’ve begun work on a set of classes & controls to help developers work with jQuery in a .NET application.

So far, I’ve composed a jDiv class to use from code behind to generate clean Div tags with as many classes & custom attributes as you like. Also, you can add as many children jDiv elements as you’d like and then just call the parent’s .ToString() method to output all of the markup. This may sound simple, but it is a great tool when you want to use server side C# or VB to output some data, then you want to use jQuery to animate it. The .ToString() method will output the markup, which you can easily output to a clean div.

Continue reading

Editing the View of a List in SharePoint Designer

I ran into a problem earlier this week where I needed to add an image link to a view in SharePoint 2010. After some head scratching and googling, I came across a good walk though on This Blog that shows you how to edit the  list view markup to contain a custom image.

Before you do this, make sure you throw a few test items in your list, it allows you to select the hyperlink in design view.

If you read the blog link posted above, then skip this next step. But before adding the image you’ll need to either write or generate some xsl script. The easiest way to do this is to let SharePoint Designer generate it for you by opening your list in SPD. When you follow the steps below, SPD automatically converts the standard List View into an XSL List View.

Continue reading

Conditionally Hiding the Ribbon Based on User Permissions

So, I recently needed to hide the SharePoint 2010 ribbon. After trying several different options, I found a very simple, but solid, solution.

To start you’ll need to crack open your master page in SharePoint designer.

Next, find the <div id=”s4-ribbonrow” class=”s4-pr s4-ribbonrowhidetitle”> tag that should be just a few lines below the head tag on the standard SharePoint 2010 V4 master.

Now, you’ll want to add a SPSecurityTrimmedControl to the page like the one below.

Continue reading

SharePoint Ribbon Modifications – Ribbon Buttons Too Small

So I was working on getting some content into the top right hand corner of the ribbon and the strangest thing happened: the ribbon buttons began shrinking themselves as if you’ve re-sized the browser. Check out the image below for an example of what happened.

At first, I thought it was due to a rogue style effecting the ribbon buttons, but with a closer examination of the source of my trouble I realized SharePoint was in fact scaling down the ribbon because of a style I set on a container to the right of the ribbon.

The CSS class that was causing my trouble was the s4-trc-container-menu. I mistakenly applied a float: right and a set width. SharePoint didn’t react well to either of those. The ribbon would shrink all the time with it floated to the right. As for the set width, the Ribbon began to display errors for me at about 400px.

Bottom line: Don’t float anything next to the ribbon, it can cause it to behave erratically.

Populating a Drop Down Based on Content Type

Recently, I’ve had to populate a drop down with lists of a certain content type. So, SharePoint offers a great way to filter lists based on content types with their ContentTypes.BestMatch() and .IsChildOf()  functions.

In order to get the content type you’ll need, you’ll have to know the ID of the content type. Theses are pretty cyptic, but you can find a great MSDN Article containing a description of how content types are composed Here.

Continue reading

Styling List View Web Parts – SharePoint 2010

The SharePoint 2010 list view web part can be styled just like anything else, there are just a few key tags you need to hit. I’ve taken the classes and ids you’ll need to hit and gathered them together and added comments to save you the hassle of navigating through SharePoint 2010’s CSS structure.

To get started, first create an additional Style Sheet and link it on the master page you are using on your SharePoint Site. Make sure you put the link to your new style sheet at the bottom of the head tag.

After that, just copy and paste the CSS below into the style sheet that is linked to your custom master page and style away.

Continue reading

Getting SharePoint Search To Work With Anonymous User Access

So, I recently started working on getting SharePoint working as an externally facing site. The more i work with it the more work arounds I end up using.

Getting SharePoint search working was interesting. First of all, since it is externally facing, our configuration require claims based authentication and Forms Based Authentication (FBA) as well.

The first problem I ran into was getting it to work at all on our externally facing site. To do so, I needed to do a few things:

Continue reading