Writing <br> in HTML using C#

J

Jeffrey Palermo [MCP]

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

This will work for any html tag.

Best regards,
Jeffrey Palermo
 
L

Lau Lei Cheong

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?
 
C

Cowboy \(Gregory A. Beamer\)

A LiteralControl can also work here.

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

*************************************************
Think outside the box!
*************************************************
 
S

Steve Burks

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?
 
S

SteveB

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.
 

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

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top