How can I add a line break or html inside of a Panel? How can I add a line break or html inside of a Panel? asp.net asp.net

How can I add a line break or html inside of a Panel?


Use the LiteralControl class to insert a line break...

MenuPanel.Controls.Add(new LiteralControl("<br />")); 

Or use CSS to make your links block-level elements...

#menu a { display: block; }


I know this answer has already been accepted but I'd like to suggest a different option. If you want a vertical list of elements then it might be worth using a ul or ol element. This means you don't have to use the dreaded br tag or any hacks to get what you need.


FYI : If you have already added the panel control in the aspx(design-view) and if you want to use the above accepted answer in .cs file (code-behind)., then you will be running into type errors. So in that case, you could use this way. Please note the small cased "new".

Panel1.Controls.Add(new LiteralControl("<br>"));