Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am designing a custom web part that basically wraps the existing PageViewerWebPart. I am doing this because I want to have some properties hard-coded and I want the URL to be formed dynamically when the site page loads.

However, I am having problems getting scroll bars to disappear whenever I start resizing the page viewer control in my code. Here is what I have currently written:

[ToolboxItemAttribute(false)]
public class VisualWebPart1 : System.Web.UI.WebControls.WebParts.WebPart
{
    protected override void CreateChildControls()
    {
        // Create a page viewer with the attributes that we want.
        PageViewerWebPart customPageViewer = new PageViewerWebPart();

        customPageViewer.ContentLink = "http://www.google.com";
        customPageViewer.Height = "8.5in"; // scrollbars appear whenever a value is set here
        customPageViewer.Width = "11in"; // same if a value is set here
        customPageViewer.SuppressWebPartChrome = true;
        customPageViewer.ScrollBars = ScrollBars.None;
        //customPageViewer.Wrap = true;

        // Manipulate our custom web part.
        this.Height = new Unit(8.5, UnitType.Inch);
        this.Width = new Unit(11, UnitType.Inch);
        this.ChromeType = PartChromeType.None;
        this.ScrollBars = ScrollBars.None;

        // Add the page viewer to our web part.
        this.Controls.Add(customPageViewer);
    }
}

Now, if I don't set height or width for either the page viewer or for "this", the Google website appears without scrollbars, and it appears that the width defaults to the width of the browser and the height defaults to about 200 pixels (so the bottom of the page gets cut off).

If I set the height and width of "this" (the web part itself), I am able to stretch out the width and height of my custom control. However, the page viewer itself remains the same, as expected, too small.

But, if I set the height or width of my page viewer, the scroll bars always appear =(

And they always seem to have just a tiny amount of space for scrolling (maybe 15 pixels wide or vertically). I've tried seemingly endless combinations of heights and widths for both the page viewer and the custom web part, and I cannot get the scrollbars to disappear. I do have ScrollBars set to None for both properties. I've tried this for various website URLs and also my web app URL, and all the results are the same. The scroll bars appear and they have about 15 pixels of scrollability each.

I need the actual screen of the website to take up 8.5 inches by 11 inches and the custom web part needs to be the same size or just bigger to fit the page viewer; in the end the whole thing is 8.5 x 11 inches. Even if I make both the page viewer and the custom web part 2000 pixels wide or high, scrollbars still want to appear with a small amount to scroll in the bar.

Anyone know how I resolve this? Thanks!

share|improve this question
add comment

3 Answers

Try setting the css property

overflow: hidden;

You might need to fiddle around to see which element to apply it to. You might also need to apply it using jQuery if you can't do it from within you code (depends upon which element causes the scrollbars). Use either the IE Developer toolbar or Firefox/Firebug to isolate the offending element.

The developer toolbar is either downloadable or if you have newer versions of IE just press F12.

share|improve this answer
add comment
up vote 1 down vote accepted

Hey guys, it turns out that

customPageViewer.SuppressWebPartChrome = true;

was causing all the unexpected behavior.

I deleted this line and replaced it with:

customPageViewer.ChromeType = PartChromeType.None;

Then I deleted the code where I was setting this.Height and this.Width. Now whenever I set customPageViewer.Height and customPageViewer.Width, the page viewer stretches or contracts to the set size, and the border of my web part by default stretches to "just enough" to fit the page viewer.

I just need to override the property window settings for height and width so that it changes the page viewer height and width, and the web part should automatically adjust correctly.

share|improve this answer
    
Thanks for sharing your solution. Helps future folk with the same problem. –  Neil Richards Feb 2 '11 at 22:07
add comment

Have you thought about using some javascript (output by your wrapper web part) to dynamically resize the iframe rendered by the page viewer web part? That might help you get the results you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.