Bootstrap styling for ASP.NET RadioButtonList and CheckBoxList in Horizontal Forms

John Avis by | July 13, 2015 | Bootstrap ASP.NET Web Forms

Following on from my last post about improving Bootstrap styling and accessibility for ASP.NET RadioButtonLists and CheckBoxLists, in this post I offer a solution for styling these controls within Bootstrap horizontal forms.
Following on from my last post about improving Bootstrap styling and accessibility for ASP.NET RadioButtonLists and CheckBoxLists, Better styling and accessibility for ASP.NET controls using Bootstrap 3, in this post I offer a solution for styling these controls within Bootstrap horizontal forms.

This example below uses the same CSS changes as my last post, but with a revised HTML structure to suit Bootstrap's form-horizontal classes.

<div class="form-horizontal">
<fieldset class="form-group">
<legend class="col-sm-3 control-label">Label for CheckBoxList1</legend>
<div class="checkbox checkboxlist col-sm-9">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Vertical" RepeatLayout="Flow">
<asp:ListItem Text="Option one"></asp:ListItem>
<asp:ListItem Text="Option two"></asp:ListItem>
<asp:ListItem Text="Option three"></asp:ListItem>
</asp:CheckBoxList>
</div>
</fieldset>
<fieldset class="form-group">
<legend class="col-sm-3 control-label">Label for RadioButtonList1</legend>
<div class="radio radiobuttonlist col-sm-9">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Vertical" RepeatLayout="Flow">
<asp:ListItem Text="Option one"></asp:ListItem>
<asp:ListItem Text="Option two"></asp:ListItem>
<asp:ListItem Text="Option three"></asp:ListItem>
</asp:RadioButtonList>
</div>
</fieldset>
</div>


And here's what this looks like:

After CSS changes

Related Posts

Bootstrap

Bootstrap 4 white buttons and input groups with button addons

by John Avis | June 29, 2018

Bootstrap 4.x doesn't give you white buttons by default, but sometimes white buttons look better, particularly for something like a search box using an input group with button addon placed on a navbar.


Bootstrap

Improving Bootstrap 4 modals on small screens

by John Avis | June 27, 2018

Bootstrap modals are great but on small screens they take up more valuable space than necessary.


Bootstrap Responsive Web Design

Responsive collapsing search filters in Bootstrap 4

by John Avis | March 26, 2018

In responsive design there are times when on a mobile screen you want to hide some options with a button to show them, but on a large screen always show these options.

Comments

There are no comments yet. Be the first to leave a comment!

Leave a Comment
Tags
ASP.NET Html Forms ASP.NET MVC ASP.NET Web Forms ASP.NET Web Pages Bootstrap C# Classic ASP Cool Websites Databases eBay and PayPal Electrical Repairs General Hardware HTML/CSS Jquery/Javascript Media Center Mobile Phones Responsive Web Design SEO and Social Networking Web Design Web Development Web Security web+db Website Hosting Windows XP Youtube

About me

...mostly about web development and programming, with a little bit of anything else related to the Internet, computers and technology.

Subscribe

Get the latest posts delivered to your inbox.