I am developing a web part and it loads correctly, however when it is set to a fixed height a DIV is appearing before my rendered content with a height set that is the same as the fixed height I set for the Web Part. The DIV still appears when there is no fixed height set, however because it doesn't have a height set it doesn't affect the display.

<div webpartid="432f1246-8d45-457f-b383-2dd390cda41f" webpartid2="06f22f6d-6484-492f-b5ae-37e13061736e" haspers="false" id="WebPartctl00_ctl39_g_06f22f6d_6484_492f_b5ae_37e13061736e" width="100%" class="ms-WPBody noindex ms-wpContentDivSpace " allowremove="false" allowdelete="false" allowexport="false" style="height:400px;overflow:auto;">
  <div id="ctl00_ctl39_g_06f22f6d_6484_492f_b5ae_37e13061736e" style="height:400px;">
// My code is rendered here

I am rendering the controls to the page by overriding the Render function:

protected override void Render(System.Web.UI.HtmlTextWriter writer)
  string Content = RenderSliderItem(GetSliderItems());
  if (!string.IsNullOrEmpty(Content))
    StringBuilder sb = new StringBuilder();
    if (HideNavigation)
    sb.AppendLine(RenderWrapper(SliderWidth, ThemeName.ToString().ToLower(), Content));

I have read that Render() shouldn't be overridden, however I couldn't work out how to use the CreateChildControls() function. I am not sure if the content should be rendered within that DIV and using CreateChildControls() will resolve this issue.

Could you please advise how I could go about fixing this so that the rendered content appears at the top of the web part?

This is a Farm Solution for an in-house installation of SharePoint 2013.

1 Answer 1


I have worked out that the base.Render(writer); line was adding the DIV. Removing this line brought by DIV to the top of the Web Part and fixed the issue.

Your Answer

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

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