473,761 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use HtmlControls or manual output

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.placeHolde r.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

Jul 4 '07 #1
2 1173
The recommended method is to setup html in the .aspx file rather than add it
programmaticall y. 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
<sj**@randh.org wrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
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.placeHolde r.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

Jul 4 '07 #2
On 4 Jul, 16:36, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
The recommended method is to setup html in the .aspx file rather than add it
programmaticall y. 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/egoldinhttp://usableasp.net
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

Jul 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1385
by: Gordan | last post by:
I have html_errors set On and it's visible that it's on because I get some parts of the error messages bold. The problem is I can't get any links to point to the PHP manual. docref_root = "/php_manual/" docref_ext = ".html" are set but no links are appearing. By that I mean there are absolutely no <a> tags or anything of that sort in my error outputs. I tried generating almost every type of error but please if somebody could post a line...
0
1361
by: Jill Graham | last post by:
Hi folks, The pages of my website are built dynamically and are based on templates. A template can look like this : <table> <tr><td>This is the page header</td></tr> <tr><td>This is the page content</td></tr> <tr><td>This is the page footer</td></tr>
3
4872
by: Martin Eyles | last post by:
Hi, I have a routine that uses System.Web.UI.HtmlControls.HtmlGenericControl.Controls.Add quite a lot to add <v:line>, <v:rect> and <div> tags to a document. Unfortunately, the output HTML markup is VERY messy, as all the tags and their contents end up on the same line. Is there a way to make it so that the output is nicely indented, and each tag is on a new line? (ie. looks like a bit like this)
2
2668
by: Sean Carey | last post by:
I converted a C# Upload app to VB.NET and am down to one error and was hoping someone could help me with te error. I would greatly appreciate help from anyone. Here is the error: c:\inetpub\wwwroot\admin\filemanager.aspx.vb(76): Expression is of type 'System.Web.UI.HtmlControls.HtmlInputFile', which is not a collection type.
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.