2

This is more or less the same as this question, Difference between HtmlTable and TagBuilder("table") and Why use TagBuilder instead of StringBuilder?

but I want to know that we when you do not have a .Net class for an HTML tag (like iFrame) in System.Web.UI.WebControls and System.Web.UI.HtmlControls then what to use?

@Edit: Can somebody tell me the difference between TagBuilder and HtmlGenericControl ?

Community
  • 1
  • 1
amitbansalite
  • 309
  • 1
  • 6
  • 13

1 Answers1

3

You can use the HtmlGenericControl to represent any element:

HtmlGenericControl iframe = new HtmlGenericControl("iframe");
iframe.Attributes["src"] = "http://guffa.com/";

Edit:

The main difference between a HtmlGenericControl and the TagBuilder is that the control is made to work in a control hieararchy that you use to build the page, while the tag builder is only used to create the HTML code for a single tag. The control can for example have child controls, while you add child tags in a tag builder by first rendering them as strings and put them in the InnerHtml property.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005