get checkbox text on same line as control using asp:CheckBox control

Viewed 136

I have found numerous references to this but still cannot get it to work. Several people have pointed to a previous post from 7 years ago that has a similar sounding problem but as detailed below the solution for that does not work at all.

I have the following asp code:

<asp:CheckBox id="checkbox1" runat="server" Style="display:inline;"
     AutoPostBack="True" Text="Send Emails" TextAlign="Right"/>

It displays like this:

bad display

If I go into the elements explorer in Chrome I see the following:

enter image description here

If I manually add the style attribute to the input line like this (using the Chrome Elements right click menu), it works:

enter image description here

What am I doing wrong and how can I fix this?

Update: This is the "solution" I wound up doing:

 <div >
   <input id="checkbox1" type="checkbox" name="checkbox1"  style="display: inline"/>
   <label for="checkbox1">I would like to receive periodic email</label>
 </div>

While this works it is obviously just avoiding the question entirely by switching to a HTML control vs ASP.

1 Answers

There could be a solution. As asp:CheckBox creating three controls and the ID is checkbox1 try the css for ID's

#checkbox1
{
   display:inline !important;   
}

This should work properly.

Related