Author Archives: Eric Webb

SharePoint Top Nav Dividers

In a client project I’m working on, the design calls for dividers in between each navigation link. No problem. Here’s the CSS:


.ms-topnav a
{
	border-left-style:solid !important;
	border-left-color:#fff !important;
	border-left-width:1px !important;
	padding: 0 10px 0 10px;

}

However, this leaves the border on the first element of the navigation, which we don’t want. There’s no way to select that element using just CSS, so JQuery to the rescue:


$(document).ready(function(){

	$(".ms-topNavContainer").each(function() {

        var links = $(this).find("a");

        if (links.length > 0) {
            var link = links[0];
            $(link).addClass("navLast");
        }

    });

});

The CSS for “navLast”:


a.navLast
{
	border-left-style:none !important;
}


The interesting thing here is that it has to be “a.navLast”. For some reason, “.navLast” doesn’t work. Also, you can’t use “border-left” to add the dividers. You have to use the individual styles (most likely because of the inline styles on the element).

SharePoint base css

Here’s a simple stylesheet that I’m going to start using as a basis for customizing all of my Sharepoint team sites.

CleanCSS


/* Top Bar */
.ms-globalbreadcrumb
{
	background-color:#7caf72;
}

/* Header */
.ms-globalTitleArea
{
	background:none !important;
}

/* Navigation */
.ms-bannerContainer, .ms-pagemargin, .ms-navframe, .ms-leftareacell
{
	background:none !important;
}
.ms-nav
{
	background-image:none !important;
}
.ms-topnavContainer, .ms-topnavselected, .ms-topnav {
	border: none;
	background: none;

}

table.ms-topnavselected, table.ms-topnav {
	height: 30px;
	margin-left: 1px;
	margin-right: 1px;
}
.ms-topnavContainer div
{
	background-color:transparent !important;	
}
.ms-topNavFlyOuts, .ms-topNavFlyOuts a:link
{
	background-color:transparent !important;
}
/* Body */
body {
	text-align: center; 
	margin: 0px auto;
}
body.ms-BuilderBackground {
    text-align: left !important;}
.ms-main
{	
    background: #fff;  
    width: 1020px !important;
    height: 100%; 
    margin: 0px auto !important;	
    border-bottom:10px #7caf72 solid;
}
table.ms-main 
{
	text-align: left;
}
/* Gets rid of default light blue background everywhere */
.ms-pagemargin, .ms-nav, .ms-pagebottommargin, .ms-pagebottommarginleft, 
.ms-pagebottommarginright, td.ms-rightareacell div.ms-pagemargin, .ms-titlearealeft,
.ms-titlearearight, .ms-titleareaframe, .ms-pagetitleareaframe, 
.ms-pagetitleareaframe TABLE, .ms-bodyareapagemargin, .ms-bodyareaframe, 
.ms-areaseparatorright, .ms-areaseparatorleft
{
	background: transparent !important;
	border: none;
}

.ms-pagebreadcrumb a {
	background-color: transparent;
	color:#fff;
}

Windows 7/Server 2008 R2 Boot to VHD

Found this great tutorial on creating bootable, sysprep’d VHD’s on the fly here.

I plan on trying this out later this week and posting my findings.

Big javascript post

All of this javascript goodness became useful while I was using jquery to call Sharepoint web services, specifically after I wrapped all of the functionality into a class.

1.  Context – this issue arose while using jquery’s .ajax() method as so:


  $.ajax({
            url: "../_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: this.processResult,
            contentType: "text/xml; charset="utf-8""
        });

I kept getting an error saying it couldn’t find the processResult() function. Turns out the “this” keyword wasn’t returning the context of the class. Instead, it was returning the context of the ajax() function call. After searching the intrawebs, I came accross this article. So, by adding the code and changing “this.processResult” to “$.context(this).callback(‘processResult’)” the problem was solved.

1A. Context and Recursion – this issue occurred while using a recursive function to write out a menu with child elements. Once again, this worked fine until I put everything into a class. However, once I did that, I started getting some weird issues with my for loop. The counter would increment twice while the recursive call was made. I wasn’t able to figure this one out, so I just unrolled the function.

2. Array sorting (mostly for my benefit) – a cool way to sort an xml array in descending order:


   this.sortRows = function(a, b){
        return ($(a).attr("columnName") - $(b).attr("columnName"))
    }

Then call the function like this:


   array.sort(this.sortRows);

Ensure Infopath Forms open in browser

Here’s a good way to ensure all of your Infopath Forms open in a browser, no matter where they’re linked from:

http://www.sharepointblogs.com/koning53/archive/2009/06/10/ensuring-infopath-forms-to-open-in-forms-services.aspx

New site

A site I’ve been developing for my wife’s uncle’s business just went live:  tateinsurancegroup.com.

Pretty standard site so far.  The one cool thing is it was done using Umbraco, an open-source ASP.Net CMS system.   There were a few hiccups I encountered when first getting the site setup, but it’s proven to be a very capable CMS solution.  I would absolutely consider it in the future.

Vista/Server 2008 Not Shutting Down

This is mostly for my purposes…

If you’re having trouble with Vista/Server 2008 not shutting down, try running:

fsutil resource setautoreset true C:

and then restarting your computer.  This resets the NTFS transaction logs on your C: drive which apparently can become corrupted.  As a bonus, I think it sped up start-up as well…

Configuring and Deploying Anonymous Publishing Sites for SharePoint Server 2007

Helpful article just posted:

http://msdn.microsoft.com/en-us/library/dd638968.aspx

Handy Regular Expressions

While working on a Sharepoint css file, I was able to use a nift regex instead of copying and pasting all over the place.

The tag I had looked like this:

#MSOZoneCell_WebPartWPQ4 td h3 a

I wanted to add a tag on the end so that it looked like this:

#MSOZoneCell_WebPartWPQ4 td h3 a, #MSOZoneCell_WebPartWPQ5 td h3 a

I used this Regex in Sharepoint Designer to do so:

Find

#MSOZoneCell_WebPartWPQ4 {.*$}

Replace

#MSOZoneCell_WebPartWPQ4 1, #MSOZoneCell_WebPartWPQ5 1

The “1” is called a “Tagged Expression”.  It refers to the part of the value that is tagged in the “Find” syntax.  You tag something using brackets, so in this case “.*$” was tagged, which corresponded to this part of the result ” td h3 a”.  I had about 10 of these, so this saved me a lot of time.

.Net Logging Framework

Found a fantastic logging framework for .Net:

http://www.theobjectguy.com/dotnetlog/

It’s very lightweight, has a ton of loggers already defined, and is easily extensibile.  The feature that drew me to it was the ability to log to multiple places at once and to filter what type of entry gets logged to each location.  For instance, I wanted to log everything to a text file but only log exceptions to the Windows Event Log.  With this framework, it was no problem.

Switch to our mobile site