Search This Blog

Tuesday, May 3, 2011

Remove the Scroll Bar from a Custom SharePoint Web Part


Normally this should be pretty straight forward.  However, today I had a custom Silverlight web part that had the vertical scroll bar appear whenever I set it to a fixed height.  It wasn't that the content was too large for the fix height, it just felt I needed the scroll bar and no matter how large I set the height, it still appeared.  The fix to removing the scroll bar is to add the CSS:

#ctl00_m_g_4d68d6ac_9970_465f_8541_e7a54d4ae37b{overflow: hidden !important;}

That's all fine and dandy except for the fact that this ID changes every time you add a web part to the site.  So if this is a web part you are going to allow others to add or deliver to a client, you don't want to manually have to add the CSS every time a new web part gets added.  So, my work around was adding the following code to the code behind for my web part.


Where the Title.Contains("[Title"]) is the title that is assigned to the web part rather than the "Display Title" which is the title that can be changed when editing the web part properties on the page.




This will make sure the scroll bar is hidden no matter what the user may title the web part.  Also, in my case, I put it in a for loop due to the fact that this custom Silverlight web part may be placed on the site multiple times and I need to hide the scroll bar in each instance of the web part.

This is the best way I found to hide the scroll bar.  If anyone else has a better way or even a more efficient way of getting the ID for a particular web part I would love to hear it.

9 comments:

  1. www.internetworkconsulting.net

    I will show you the easiest way.

    ReplyDelete
  2. Thanx for the contribution, it is working fine but the limit is when a SharePoint user changes the title.

    Have you seen another solution to do the work ?

    ReplyDelete
  3. Just want to say your article is as surprising.
    The clearness to your publish is simply excellent
    and i could assume you are knowledgeable on this subject.
    Fine with your permission allow me to grasp your feed to stay up
    to date with imminent post. Thank you 1,000,000 and please keep
    up the gratifying work.

    My page - Ways to get gone moobs withinside Thirty days

    ReplyDelete
  4. I am really loving the theme/design of your web site. Do you
    ever run into any internet browser compatibility issues?
    A small number of my blog readers have complained about my website
    not operating correctly in Explorer but looks great in
    Safari. Do you have any suggestions to help fix this problem?


    Feel free to visit my blog chestfatburner.com

    ReplyDelete
  5. This article is genuinely a nice one it helps new web people, who are
    wishing in favor of blogging.

    Feel free to surf to my web page - chestfatburner.com

    ReplyDelete
  6. magnificent points altogether, you simply received a new reader.

    What could you suggest in regards to your put up that you made
    a few days in the past? Any sure?

    Feel free to visit my homepage Gynecomastia in age of teenage life and later Years

    ReplyDelete
  7. Do you have a spam issue on this website; I also am a blogger, and I was wondering your situation; we have developed some nice practices and we are
    looking to swap strategies with others, why not
    shoot me an e-mail if interested.

    Also visit my homepage - chestfatburner.com

    ReplyDelete
  8. Hi, if you are interested in solution for SharePoint 2013, I found this works for me:
    this.Style.Add(HtmlTextWriterStyle.Overflow, "hidden");
    where this is current web part, I work with SharePoint 2013 visual web part.

    ReplyDelete
  9. And then I work my way around and I say it when I home improvement
    designs speak-- that I'm connected to this and
    I'm sure everybody in this room connects to what comes out of my private practice.
    Published by Antique Collectors' Club, the book is available from the moment
    that you boot up your Samsung Galaxy home improvement designs SII mobile phone for the first time.
    They have small, immediate financial needs.

    Also visit my blog Osceola Fence Supply

    ReplyDelete