Use HtmlControls or manual output

Discussion in 'ASP .Net' started by sjur@randh.org, Jul 4, 2007.

  1. Guest

    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
     
    , Jul 4, 2007
    #1
    1. Advertising

  2. 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


    <> wrote in message
    news:...
    > 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
    >
     
    Eliyahu Goldin, Jul 4, 2007
    #2
    1. Advertising

  3. Guest

    On 4 Jul, 16:36, "Eliyahu Goldin"
    <> wrote:
    > 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/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, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gopal Prabhakaran

    Difference between HtmlControls and server controls

    Gopal Prabhakaran, Jan 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,431
    Rainer Maurer [MS]
    Jan 26, 2004
  2. szabelin
    Replies:
    0
    Views:
    473
    szabelin
    Aug 4, 2003
  3. Paul Russell

    HtmlControls doesn't expose GridLayoudPanel?

    Paul Russell, Nov 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    Paul Russell
    Nov 3, 2003
  4. Marco Scheel
    Replies:
    3
    Views:
    776
    Jacob Yang [MSFT]
    Nov 26, 2003
  5. Greg Linwood

    Access HtmlControls in code-behind

    Greg Linwood, Dec 2, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    4,065
    Bharat
    Dec 2, 2003
Loading...

Share This Page