måndag 20 december 2010

Style SharePoint 2010 lightboxes

The lightboxes in SharePoint 2010 is kind of nice. They allow you to open your pages in a modal (resizable) window. By default, the top navigation and quick launch will be hidden in the lightbox. This is done by adding the class s4-notdlg to the containing html element.

If you want some special style on an object when it is opened in a lightbox you use the class ms-dialog

Examples:
<span class="s4-notdlg">This will not show in lightboxes</span>

<style>
/* Makes the body background pink in a lightbox */
.ms-dialog body
{
background-color: pink;
}
</style>

PS.
Open a lightbox with the following JavaScript:
var options = {url: http://myspsite/default.aspx};
SP.UI.ModalDialog.showModalDialog(options);DS.

tisdag 7 december 2010

Add SafeControl entries with Visual Studio

Sometimes it is necessary to add SafeControl entries to your manifest.xml file manually. In Visual Studio 2010 you can either edit the manifest directly (by open the Package node of your project, view the Manifest and click on Edit Options) OR you can do it the safe and easy way:
  • Mark your element / module node
  • Find the "Safe Control Entries" in the properties and click the [...] button
  • Click the Add button on the dialog
  • Change the properties if necessary, and click ok.
Your SafeControl entries will now be added to the web.config.

JavaScript error in Ribbon dropdown

Today I ran in to a very strange issue with SharePoint 2010. All of a sudden, the dropdown menus in the ribbon started to throw javascript error - "null is undefined".

My first guess was that some of our javascript files caused the error (we have quite a lot of code running on the page and in the ribbon). But the error still occured after I disabling all our custom js code.

It later turned out that the error was caused by a empty CSS file! What the h*ll! Ok, fine. You shouldnt load an empty file, but doing so shouldnt break the functionality of the ribbon!

FYI: We loaded the file with CssRegistration.Register("<filename>");

Run C# code in PowerShell

Do you have any utility you written in C# that you dont want to rewrite for PowerShell? If you use PowerShell V2 you dont need to. Theres a nifty little cmdlet named Add-Type that generates a new .Net assembly using a C# code file. The new assembly is placed in memory and is available from your PowerShell script. Read more about it at Stefan Gossners blog: http://blogs.technet.com/b/stefan_gossner/archive/2010/05/07/using-csharp-c-code-in-powershell-scripts.aspx

Testing with different users

I'm always frustraded when I need to test my code with different users. Login / logout takes forever... ;-)

But if you use the InPrivate browsing feature in IE you can be logged in with multiple users at the same time! Happy times!

måndag 6 december 2010

typeof() in PowerShell

Today I needed to check if an object was of a specific type in PowerShell. The typeof() statement doesnt work, you should use [ ] instead. Like this:
$feature.Parent.GetType() -eq [Microsoft.SharePoint.Administration.SPFarm]

söndag 5 december 2010

Change text on claims based login page

Have you ever wanted to change the display text in the dropdown for a claims based login page? It's easy done with jQuery:

<script>
$(document).ready(function() {
$("select option[value='none']").text("Make your selection...");
$("select option[value='Windows']").text("AD users");
$("select option[value='Forms']").text("External user");

});
</script>


Just make sure that you have loaded jQuery before you run the script...

onsdag 1 december 2010

Turn off Attach Security Warning

Do you get the disturbing Attach Security Warning every time you attach your debugger to a process? Make sure that Visual Studio is turned off, then change the following register key to 1 (true): HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger\DisableAttachSecurityWarning.

If Visual Studio isnt closed, the value will change back to 0. This should work for older versions of VS as well.

tisdag 23 november 2010

First post

Just testing the new blog...

I will use this blog to help myself remember stuff that I probably will need to do some other time. But maybe it will help someone else to...


//Martin