I'm in a situation where I want to grab the web part controls and/or HTML content of the controls for a publishing page, and format the content before it is rendered.

How can I go about this? I've thought about using a UserControl to run server-side code, or perhaps in the layout that the content resides in? However, the layout is in the design manager.

How can I access this published page content before it is rendered?

Edit: The end goal is to allow users to specify HTML tags (i.e. data- attributes) and handle them on the server-side to hide and display content based on varying business scenarios; thus, allowing them to easily add/edit content that will be displayed dynamically).

SharePoint 2013 - On premise

1 Answer 1


You can use Page.Controls for getting the control in Server Side.

From your update I think below approach will work

  1. Create a Custom List to capture fields to Hide
  2. Now using Browser Tool find the element id and store it in the configuration list
  3. Now you need to take a decision whether to user Client Side or Serve Side
  4. If client side - Then use a Script Editor Webpart and user JavaScript to read custom configuration list and use jQuery to hide elements
  5. If server side - Then create a new webpart and read configuration list and iterate through Page Controls and remove or hide elements.

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.