I'm looking to create a part of a HTML page as a WebPart (not Visual WebPart) in Sharepoint 2010, and I'd like to understand the classes available within the WebPart to create HTML components.

Currently, I know of a few:
Panel - creates a <div>
Button - creates a <button>
Label - creates a <label>
DropDownList - creates a <select> (dropdown)
ListBox - creates a <select size='...'> (listbox)
TextBox - creates a <input type='text'/>
LinkButton - creates a <a href=...>

Could you provide a full list of controls available in WebPart? (For example, how do I create a <span>?)

This is mostly what I was looking for: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.aspx, though this list doesn't directly mention which HTML component results from adding the control to the page.

  • This is a broad question, and to me more related to ASP.net than it is to SharePoint per se. I think you should ask this question on StackExchange instead. Dec 9, 2013 at 11:00

2 Answers 2


In a Sharepoint WebPart you can create any ASP.NET control as you have shown above!

If for example you want a direct HTML control to be added to the page than you would need to do this:

this.Controls.Add(new LiteralControl("<div id='htmlDiv'>"));
this.Controls.Add(new LiteralControl("<a href='http://www.google.com'>this is a html link</a>"));
this.Controls.Add(new LiteralControl("</div>"));

As it is so broad in the amount of controls you could test the results!

Within the CreateChildControls() do:

TextBox tb = new TextBox();
tb.ID = "tb";
tb.Text = "test";

The above would add a TextBox to the page! Go into the browser and hit F12 to get developer tools running and inspect the HTML generated!

I suspect that it would be an <input> tag generated ;) for TextBox and most other controls like button, label etc!

  • Thanks! I will use this approach to create the <span> I wanted. Check my update to the question, and please post if you know which controls directly translate into which HTML components.
    – SNag
    Dec 9, 2013 at 11:23
  • just ammended my answer!
    – Ali Jafer
    Dec 9, 2013 at 11:30
  • Many thanks! I shall try this, and publish the full list of the controls vs. HTML components here if I can.
    – SNag
    Dec 9, 2013 at 11:44

As far as the client (browser) is considered, SharePoint page (and WebPart as the part of the page) is just normal HTML document and therefore every HTML tag is valid tag in any SP page (and WebPart).

  • You've probably misunderstood my question. I'm looking for the names of ASP.NET classes that translate directly into HTML tags on a page. For example, Panel creates a <div>, when added to the page using this.Controls.Add(new Panel()); So what class creates a <span>? What creates a <h1>? And so on.
    – SNag
    Dec 9, 2013 at 18:51

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.