Writing <br> in HTML using C#

Discussion in 'ASP .Net' started by SteveB, Oct 25, 2004.

  1. SteveB

    SteveB Guest

    How can I write a break on Web Form using C#?
     
    SteveB, Oct 25, 2004
    #1
    1. Advertising

  2. HtmlGenericControl lineBreak = new HtmlGenericControl("br");
    Page.Controls.Add(lineBreak);

    This will work for any html tag.

    Best regards,
    Jeffrey Palermo

    "SteveB" <> wrote in message
    news:...
    > How can I write a break on Web Form using C#?
     
    Jeffrey Palermo [MCP], Oct 25, 2004
    #2
    1. Advertising

  3. 1) Resonse.Write("<br>");
    Probably the following will do too...
    2) Page.Controls.Add(new System.Web.UI.HtmlControls.HtmlControl("br"));

    But what's the use of that?

    "SteveB" <> ???
    news: ???...
    > How can I write a break on Web Form using C#?
     
    Lau Lei Cheong, Oct 25, 2004
    #3
  4. A LiteralControl can also work here.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************************************************
    Think outside the box!
    *************************************************
    "Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
    message news:...
    > HtmlGenericControl lineBreak = new HtmlGenericControl("br");
    > Page.Controls.Add(lineBreak);
    >
    > This will work for any html tag.
    >
    > Best regards,
    > Jeffrey Palermo
    >
    > "SteveB" <> wrote in message
    > news:...
    >> How can I write a break on Web Form using C#?

    >
    >
     
    Cowboy \(Gregory A. Beamer\), Oct 25, 2004
    #4
  5. SteveB

    Steve Burks Guest

    Thanks for the info. As far as the use here goes....

    First of all let me admit that I am very new to C#.
    I have established a database with 4 address fields. I know that at
    times some of the fields will be empty. I am using a datalist and label
    controls to present the addresses. The C# code sets the display property
    of the label. I need a break between address lines only when the label
    is displayed otherwise I have blank lines. Is there another way?


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Steve Burks, Oct 25, 2004
    #5
  6. SteveB

    SteveB Guest

    Having trouble getting the linebreak to appear in the html.
    I am using datalist and looping through each label control. If the label
    contains information I want to display and at the same time place <br>
    at that label instance. If the label is empty I want to set display to
    none with no <br>. I am able to switch the display property but I am
    having trouble with the <br> part. If I hard code the <br> they cause
    new lines even when the label is not displayed.





    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    SteveB, Oct 25, 2004
    #6
    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. Avi

    writing html (client) on aspx

    Avi, May 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    611
  2. HNguyen
    Replies:
    4
    Views:
    2,452
    HNguyen
    Dec 21, 2004
  3. Replies:
    6
    Views:
    1,644
    Mitch
    May 11, 2006
  4. Adam Akhtar
    Replies:
    9
    Views:
    590
    Florian Gilcher
    Aug 16, 2008
  5. Deryck
    Replies:
    2
    Views:
    155
    Deryck
    Sep 18, 2004
Loading...

Share This Page