Sunday 20 May 2012

Common Mistakes while SharePoint Branding(Avoid It)

1] Modifying Default Files Provided by Microsoft :
Do not modify default files is the most important thing to be followed.Default files such as JS,CSS,Master Pages which are available in 14 hive can be modified,but you will loose support and it will affect other SharePoint Sites too.
If you want to modify master pages, CSS or scripts found in the 14 hive, create a copy of the file(s), make modifications, package those up into a Feature and deploy via a Solution.
So "1st rule of SharePoint Branding is Do not Modify Default Files"

2] Using JQuery or JavaScript now and then :
Don't use excessive JQuery or JavaScript,it increases overhead.Use it when we have no option except JQuery or JavaScript.
For Example :
You want to hide Help Icon on the SharePoint Site:
 
For this no need to use JQuery .Yes we can hide it using JQuery like $(".s4-help").hide();
But the easiest way would be just add CSS Styling to hide it.
<style>
.s4-help {
    display: none !important;
}
</style>


3] Overriding the OOB CSS  :
Suppose you want to change the CSS attributes say For Example: help icon(you want to increase the width of it).Just don't change corev4.css,create a new CSS file and in that you can add the new attribute for the respective CSS class and give the reference of that file in the Masterpage.
<style>
.s4-help {
    width:100px;
}
</style>
It will not work !!!!. SharePoint site will render corev4.css class for it ..because we are not making it important.
so 
<style>
.s4-help {
    width:100px !important;
}
</style>
Common problem i have seen :)

4] Applying a Fixed Width To a Collaboration Site

A fixed width layout has a set width around the main content area and doesn’t expand to fill the browser window. When you fix the width of a site meant for collaboration and document management, you have to potential of eliminating extra space for users to add content and collaborate.

If you must fix the width on a collaboration site, fix the width of the content area using a percentage rather than a set pixel value. This ensures the maximum amount of space and focuses on function rather than form.

5] Using Inline Styling :
 Inline styles are styles applied directly to HTML content and looks like the example below: 
"<p style="color:red;"> Hey </p> "

Inline styles are the most specific and the highest priority of all other styles so it’s a prime focus to use them instead of fighting with the cascading style sheets of SharePoint.
 You don’t want to manage styling this way because inline styling mixes content and presentation (look and feel) together. 
This is a bad practice because these kind of styles are not managed at some central place, pages can become inconsistent and they are very difficult to find and correct when you are working on a very big and complex project.

6]Fixing the Width of the Ribbon

Sometimes a fixed width layout will be applied to the ribbon too. It affects and due to it administrative tools are hidden when the width is fixed.
Fixed width SharePoint Ribbon overflow problem:

Disadvantages :
  • Alters Consistency of User Experience
  • On High Resolution screen the site action almost comes in middle of the page.
Solution : Fix the width of the content area and not the ribbon :)



7] Adding CSS Directly in MasterPage :
Many times i have seen that CSS is added directly in <head> section of Masterpage.Bad Practice ,
We should maintain a different CSS file and we should add our CSS in it and just mention reference of it in the Masterpage.

Still updating it as i will encounter some more interesting mistakes :)
you can also share your views and you can also comment any other mistakes you have came across while SharePoint Branding :)







Saturday 19 May 2012

Sandbox Error : UserCodeToken Is Invalid

While deploying a new Sandboxed Solution to my farm,i encountered some what error like "UserCodeToken is Invalid"  
 
The error says "Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: The UserCodeToken is invalid". 
I didnt get any events for this error nor the message helped me to find any solution.
After spending quality time i found the solution which worked in my case.
 
Solution : Restart the service SPUsercodeV4 from PowerShell . Command "Restart-Service SPUsercodeV4" 

Hope this helps someone :)