Adding Line Breaks Between Controls in a PlaceHolder
Okay, so I’ve done this manually, but decided to refactor it up into a little method and add it to our Utility class of our framework… because it’s so inane, but so common, that.. that.. *codes self in a corner*
When adding controls to a Placeholder, there isn’t a simple way to simply insert a break between controls. For example, if you’re adding a list of links or paragraphs, you must rely on padding the control with a <br/> or <p> set to ensure padding. Well, that’s not always the case, especially for buttons.
private static Label InsertLineBreaks(int breaks)
Label lblLineBreak = new Label();
for (int i = 0; i<breaks; i++)
lblLineBreak.Text += “<br/>”;
Yes, it’s crude, yes, it’s simple… but by gosh, it saves me from retyping it.
It adds a break for each number you provide to it in it’s constructor.