views:

155

answers:

2

Hi,

I'm trying to learn how to line up fields of a form using CSS instead of tables. I'm having a hard time with a CheckBox control. Here's the code:

<html xmlns="http://www.w3.org/1999/xhtml" >

<label for="CheckBox1">CheckBox</label>
<asp:CheckBox ID="CheckBox1" runat="server" />
<br />
<label for="TextBox1">TextBox</label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<div>

</div>
</form>

Here's the CSS:

body
{
}

label
{
    width:300px;
    float:left;
}

I'm getting something that looks like this:

CheckBox []

[CheckBox1] TextBox [ ]

Why is [CheckBox1] on the next line?

Here's a pic: alt text

Also, is there a better way to do this?

+1  A: 

It's been a while since I worked on ASP.Net but if I remember correctly, the checkbox control has a property that lets you specify where the text appears (below it or to the side). That may solve your problem.

darthjit
+1  A: 

[CheckBox1] only appears in design view - if you run the application you will see that it is not there.

[CheckBox1] appears in design view because you have not set the text for the checkbox - it looks like you are using a label instead.

rip