I have several text boxes that require text, and then I have a check box list that requires one of the check boxes to be checked. I am using ASPs Custom Validator to display a red "!" when the requirements are not met. I want the "!" to be displayed right next to the textbox and checkbox lists. This is working correctly for the textbox, but when I display it next to the checkboxes it is displaying in on a new line. How can I get this to display on the same line?
CODE
<asp:CheckBoxList ID="TEST" ruant="server"
DataSourceID="TestBox">
</asp:CheckBoxList>
<asp:CustomValidator runat="server" ID="cvTEST" setFocusOnError="true"
ClientValidationFunction="test_val" ValidateEmptyText="true"
Display="Dynamic" text="!">
</asp:CustomValidator>
I have done a textbox and dropdown list both the same way, and they are working. What is the difference between those two and a checkbox list?
The checkbox list control generates a <table> HTML element, which by default is a block level element - see https://webdesignfromscratch.com/html-css/css-block-and-inline/ .
To fix this, add a CSS class to your checkbox list:
<asp:CheckBoxList ID="TEST" runat="server" CssClass="CheckBoxListStyle">
</asp:CheckBoxList>
then you can change the style so that it's rendered inline by adding the following code to the page:
<style type="text/css">
.CheckBoxListStyle { float: left; }
</style>
now with a bit of luck your exclamation point should appear to the right just like this one is!