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

What is the best way to write/output html in a webpart?

I am coming from PHP, there it was pretty straightforward.

I have seen the HtmlTextWriter, but I think that is very odd and makes it even more complicated.

Thank you!

share|improve this question
up vote 2 down vote accepted

If you just want to output HTML directly using code then you should override the RenderContents Method and call the methods on the HtmlTextWriter it gets as parameter.

But many prefer to use ASP.NET controls which should be created inside an override of CreateChildControls Method

share|improve this answer

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.