Social Icons

twitter google plus linkedin rss feed

Pages

5.8.11

Hiding the Scrollbars in the SharePoint 2010 Web Parts

After deploying the first alpha version of our solution in SharePoint 2010 I realized that my Silverlight web parts were showing ugly scrollbars. I noticed that if I change the height and width to auto they will disappear… but then my web part will not have the right size…
I read this post: http://blog.benfox.info/?p=11 and, as you could have guessed, I went for the inelegant approach.
Then I found that the javascript code was in a picture… how inconvenient… and then I thought “I’ll show everyone that I can be as dull in SharePoint 2010 as I have always been in SharePoint 2007” Why not creating a post about that?
<script type="text/javascript">

 function HideScrollBars()
 {
 document.getElementById('WebPartWPQ2').style.overflowX = "hidden";
 document.getElementById('WebPartWPQ2').style.overflowY = "hidden";

 document.getElementById('WebPartWPQ3').style.overflowX = "hidden";
 document.getElementById('WebPartWPQ3').style.overflowY = "hidden";
 }

_spBodyOnLoadFunctionNames.push("HideScrollBars")</script>
And after struggling with the new Content Editor Web Part for at least 15 minutes I finally managed to hide the vertical and the horizontal scrollbars in my web parts.
Now I can proudly send a picture of the site in the SharePoint 2010 view.

--- Update --- I have changed the web part code so we don't need to use this crappy javascript code.