I am trying to create a menu with the following code. But I cannot figure out how to get each LinkButton to appear on seperate lines.
MenuPanel.Controls.Clear();
foreach (FormList f in forms)
{
if (f.IsActive == "y")
{
FormUserControl fc = (FormUserControl)LoadControl(f.StartControl);
LinkButton lb = new LinkButton();
lb.Text = fc.Title;
MenuPanel.Controls.Add(lb);
// I want some sort of line break here
}
}
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>"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With