i am creating a dynamic Page Viewer web part from the user control code behind .. something like this:

PageViewerWebPart oWebPart = new PageViewerWebPart(); 
oWebPart.ContentLink = WebPart.WebPartContentLink.ToString(); 

the problem i am having is Height/Width.... do i need to provide user to set the height and width for the Page Viewer in the Prop window?

oWebPart.Height = "<user input>" 
oWebPart.Width  = "user input>" 

any help how should i deal with this issue?

I try to set the Height/Width of the web part that i have created through:


but no avail.

custom web part for Page Viewer web part through code-behind but i am unable to set height and width after i edit my custom web part and i select inches and set to 12 but nothing has happen...

Any Insight?

1 Answer 1


I have a brief description of how to the user can update the nested web part with the default properties editor here.

Basically, you would write something like this in your code-behind:

oWebPart.Height = this.Height  
oWebPart.Width  = this.Width

That way, your nested page viewer web part will inherit what the user typed.

The page viewer web part is just an <iframe> element in the HTML, while your web part is most likely a <div> element surrounding it. By default the <iframe> has a fixed size, which is why the default properties resizing the <div> appears to disregard resizing the page viewer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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