views:

326

answers:

1

Hi.

I am a newbie if it comes to web site development. I would like to create a web form that would contain controls defined in an XML file. This means that I am going to read the XML file within the Page_Load function and dynamically create and name all controls as defined in the file. This seams to be very easy.

I have, however, another problem, namely the layout. When I add a new control to my form, it is placed next to the control that was created previously. How can I place them one below another or put some spaces before and between them? I thought using the PlaceHolder control would help me, but I couldn't find any properties that would change the position of the controls parented by it.

Here is how I create a single control:

Label lbl = new Label();
lbl.ID = "lbl";
lbl.Text = "Test";
PlaceHolderMain.Controls.Add(lbl);

Thanks for your help in advance,

Mariusz.

+2  A: 

You have a few options:

  1. Add additional controls such as a Literal Control where the text is the HTML you want such as a <BR/> tag or nbsp; in between the controls that have been added.
  2. Have multiple Placeholder controls for each appropriate section.
  3. Use CSS to position the controls where you want them. I am not a CSS expert but this can be done but it requires an understanding of CSS positioning.
  4. Add the controls into a parent control such as a table so you can add the controls into a tabel cell within a row. It would mean creating Rows and Cells to add to the table but it would give you more control over the layout.

Hope this gives you a few ideas that can help.

CertifiedCrazy
I think that just about covers most of the available options. Great answer! +1
Cerebrus