SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to make custom properties for web parts in SharePoint, but is there a way to override the ones that are already generated? For example I have a Page Viewer embedded within my custom web part, and I would like to override the default "Height" property that the user can type a value for in the property window so that I can pass it to the height of my Page Viewer. That way the page viewer stretched to the appropriate height instead of my web part stretching, but not the page viewer. Any help is appreciated, thanks!

share|improve this question
up vote 3 down vote accepted

Just call this.Height, this.Title, this.Width (whichever default property) etc... and set them within CreateChildControls() to override what the user typed.


protected override void CreateChildControls()
    this.Title = "Foo";
    this.Height = 500;

However, this just updates the whole web part. In my question, I have an embedded PageViewerWebPart, so I would need code like this to actually get the page viewer to stretch to the size of my custom web part containing it:

protected override void CreateChildControls()
    PageViewerWebPart pvwp = new PageViewerWebPart();
    pvwp.ContentLink = ""
    pvwp.Height = this.Height;
share|improve this answer
Great! Thanks for posting the answer. – Kit Menke Aug 8 '11 at 15:56

Your Answer


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.