Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding <br/> dynamically between controls asp.net

I'm listing some controls at my web page dynamically, either I'm adding newline with Label's.

Label newLine = new Label();newLine.Text = "<br/>"; myPanel.Controls.Add(newLine); 

How can I do it in a different way?

like image 612
softwaremonster Avatar asked Jun 22 '10 16:06

softwaremonster


People also ask

How to add br tag dynamically in asp net?

Label newLine = new Label();newLine. Text = "<br/>"; myPanel. Controls. Add(newLine);

What is dynamic control in asp net?

The DynamicControl control is used by templated data-bound controls, such as FormView or ListView, to display a data field that uses ASP.NET Dynamic Data features in a custom page. You can also use a DynamicControl control in a TemplateField field of a GridView or a DetailsView control.

What is an ASP label?

ASP.NET Web Forms LabelThis control is used to display textual information on the web forms. It is mainly used to create caption for the other controls like: textbox. To create label either we can write code or use the drag and drop facility of visual studio 2017.


2 Answers

myPanel.Controls.Add(new LiteralControl("<br />")); 
like image 168
womp Avatar answered Sep 24 '22 02:09

womp


I would suggest that you don't use
at all. Use CSS to display your controls. display:block on your elements will work just fine. Less messy!

like image 42
TheGeekYouNeed Avatar answered Sep 26 '22 02:09

TheGeekYouNeed