Wednesday, January 18, 2012

Styles not working in custom forms

Scenario:
I am sure this worked in MOSS 2007. Applying OOTB styles gives perfect look and feel for custom forms. But when I applied OOTB styles in SP2010 Visual Web part , I didn't get the right styles.

Solution:
After few comparison I realized SharePoint loads different style sheet files on different pages. So for a custom form to get the same styles as OOTB forms, there was a missing stylesheet.
Add the following statement in your Visual Webpart to fix it.

Code:

<link rel="stylesheet" type="text/css" href="/_layouts/1033/styles/Themable/forms.css" />

2 comments:

Anonymous,  February 24, 2012 at 12:11 PM  

This technique worked fine for me in SP2007 (VS2010) but doesn't work in SP2010. I'm using VS2010, Sharepoint Software Factory, WSPBuilder and SP2010. All are up to date.

My link contains href="/_LAYOUTS/1033/STYLES/fullcalendar.css" and is just under the CONTROL header of the user control. The href is underlined saying the file cannot be found. In fact NO file in the 14 hive can be found using link for css or script for javascript.

This is an upgrade from a SP2007 webpart.

Any ideas?

Thanks

Sandeep February 26, 2012 at 9:14 PM  

I am using it in all my new SP2010 projects and no issues.
I will recommend trying few things

1. Use absolute url once
2. Try creating a fresh Visual WP in SP2010
3. Copy the styles in a new file and place in layouts and refer it [ may not be the best but will give u some idea's ]