System.Web.UI.HtmlControls.HtmlGenericControl.Controls.Add

Discussion in 'ASP .Net' started by Martin Eyles, Mar 31, 2005.

  1. Martin Eyles

    Martin Eyles Guest

    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)
    <div>
    <v:line ......>
    </v:line>
    <v:rect ......>
    </v:rect>
    <div>
    £-83
    </div>
    </div>

    Thanks,
    Martin

    --
    Martin Eyles
     
    Martin Eyles, Mar 31, 2005
    #1
    1. Advertising

  2. hey whereever required you can add new LiteralControl(" "),
    new LiteralControl("<br/>")

    To have the formatted HTML.

    Hope this helps.

    "Martin Eyles" wrote:

    > 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)
    > <div>
    > <v:line ......>
    > </v:line>
    > <v:rect ......>
    > </v:rect>
    > <div>
    > £-83
    > </div>
    > </div>
    >
    > Thanks,
    > Martin
    >
    > --
    > Martin Eyles
    >
    >
    >
    >
     
    =?Utf-8?B?SGl0ZXNo?=, Mar 31, 2005
    #2
    1. Advertising

  3. Martin Eyles

    Martin Eyles Guest

    "Hitesh" <> wrote in message
    news:D...
    > hey whereever required you can add new LiteralControl(" "),
    > new LiteralControl("<br/>")
    >
    > To have the formatted HTML.


    This didn't quite work, but just inserted a space or <br/> in the html. But
    I managed to modify it to do what I want. I now do

    theGraph.Controls.Add(New LiteralControl(Chr(10)))

    which inserts a newline character in the HTML.

    Thanks,
    ME

    --
    Martin Eyles
     
    Martin Eyles, Mar 31, 2005
    #3
  4. Martin Eyles

    Martin Eyles Guest

    "Martin Eyles" <> wrote in message
    news:...
    > "Hitesh" <> wrote in message
    > news:D...
    > > hey whereever required you can add new LiteralControl(" "),
    > > new LiteralControl("<br/>")
    > >
    > > To have the formatted HTML.

    >
    > This didn't quite work, but just inserted a space or <br/> in the html.

    But
    > I managed to modify it to do what I want. I now do
    >
    > theGraph.Controls.Add(New LiteralControl(Chr(10)))
    >
    > which inserts a newline character in the HTML.


    To make this neater when run several times, I have tried to split this into
    two bits

    At the top of the method I set up a literal control object object:-

    //Set up a web control to insert a new line into the HTML code.
    System.Web.UI.LiteralControl codeNewLine;
    codeNewLine=new System.Web.UI.LiteralControl(((char)10).ToString());

    And at several points I insert this line to add the control to another
    control:-

    theGraph.Controls.Add(codeNewLine); //add a new line to the HTML code.

    However, this only appears to work the very last time it is inserted.

    Any Ideas?

    Thankyou,

    Martin

    --
    Martin Eyles
     
    Martin Eyles, Apr 5, 2005
    #4
    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. szabelin
    Replies:
    0
    Views:
    462
    szabelin
    Aug 4, 2003
  2. Marco Scheel
    Replies:
    3
    Views:
    773
    Jacob Yang [MSFT]
    Nov 26, 2003
  3. Nathan Sokalski
    Replies:
    5
    Views:
    1,030
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  4. Nathan Sokalski
    Replies:
    4
    Views:
    305
    Nathan Sokalski
    Dec 21, 2006
  5. Nathan Sokalski
    Replies:
    4
    Views:
    342
    Nathan Sokalski
    Dec 21, 2006
Loading...

Share This Page