Use HtmlControls or manual output

S

sjur

Hi,

I'm in the start-phase of implementing an ASP.NET 2.0-application
which will output quite a lot of HTML to the client. The question now
is whether to use the built-in HtmlControls:

HtmlTable tab = new HtmlTable();
this.placeHolder.Controls.Add(tab);

or to manually output the HTML using this kind of syntax:

this.label.Text = "<table></table>";

One requirement of the application is to output valid XHTML 1.0
Transitional. Obviously using HtmlControls would help us write valid
XHTML but I fear this might also restrict our possibilities to output
what we need, and also require us to write much more code than needed.

If someone could please advice or recommend one method over the other
I would be most thankful.

Regards,
Sjur
 
E

Eliyahu Goldin

The recommended method is to setup html in the .aspx file rather than add it
programmatically. If you do need to add controls in the code, which very
often can be avoided, create them as controls. You can add plain text tags
as a last resort, but it is a very not-asp.net approach.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
S

sjur

The recommended method is to setup html in the .aspx file rather than add it
programmatically. If you do need to add controls in the code, which very
often can be avoided, create them as controls. You can add plain text tags
as a last resort, but it is a very not-asp.net approach.

Thanks for responding. I will look at the design to see if we can
perhaps avoid adding code from codebehind. If not we will take the
approach using HtmlControls.

Regards,
Sjur
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top