How to change CheckBoxList Control Text Align in ASP.Net

In this ASP.Net tutorials we are going to learn How to change Text Align (Left / Right) Checkboxlist Control Programmatically in ASP.Net with C#.

STEp 1 – Design the ASP.Net web form with One CheckBoxList control along with Two Button Control :

<table style=”width: 464px”>
<tr>
<td colspan=”1″ style=”width: 257px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>&nbsp;Text
Align Left / Right – CheckBoxList</span></strong></td>
</tr>
<tr>
<td style=”width: 257px; height: 24px; text-align: center;”>
&nbsp;
<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”LEFT Align” Font-Bold=”True” Font-Size=”Medium” /><asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”RIGHT Align” Font-Bold=”True” Font-Size=”Medium” /></td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center;”>
<asp:CheckBoxList ID=”CheckBoxList1″ runat=”server” Width=”168px”>
<asp:ListItem Value=”1″>ABC</asp:ListItem>
<asp:ListItem Value=”2″>DEF</asp:ListItem>
<asp:ListItem Value=”3″>GHI</asp:ListItem>
<asp:ListItem Value=”4″>PQR</asp:ListItem>
<asp:ListItem Value=”5″>STU</asp:ListItem>
<asp:ListItem Value=”6″>XYZ</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td style=”width: 257px; height: 22px; text-align: center”>
</td>
</tr>
</table>

The ASP.Net CheckboxList Control Text Align Example output is :

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#
The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

STEP 2 – write below code on Button Click event of ASP.Net code page:

 protected void Button1_Click(object sender, EventArgs e)
{
CheckBoxList1.TextAlign = TextAlign.Left;
}
protected void Button2_Click(object sender, EventArgs e)
{
CheckBoxList1.TextAlign = TextAlign.Right;
}

The ASP.Net CheckboxList Control Text Align Example output is :

The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#
The ASP.Net CheckboxList Control Text Align Example in ASP.Net with C#

 

I hope this ASP.Net CheckBoxList Contol Text Align Example will help you …..

Leave a Reply

Your email address will not be published. Required fields are marked *