How to change CheckBox Text Align in ASP.Net C#

In this ASP.Net tutorials we will learn to change the Checkbox text align programmatically in ASP.Net C# with an Example.

STEP 1 – Design the ASP.Net web page with one CheckBox control along with Two Button Control like :

<table border=”1″ bordercolor=”#000000″ style=”z-index: 100; left: 272px; position: absolute;
top: 72px”>
<tr>
<td colspan=”3″ style=”width: 582px; height: 100px;”>
<asp:Image ID=”Image1″ runat=”server” ImageUrl=”https://meeraacademy.com/wp-content/themes/elemin/uploads/logo/meeralogo.gif” /></td>
</tr>
<tr>
<td colspan=”3″ rowspan=”2″ style=”width: 582px; height: 21px; text-align: center”>
<table style=”width: 496px”>
<tr>
<td colspan=”1″ style=”width: 274px; height: 24px”>
<strong><span style=”font-size: 14pt; color: #6600cc; font-family: Arial”>Change CheckBox
Text Align Programmatically</span></strong></td>
</tr>
<tr>
<td style=”width: 274px; height: 8px;”>
&nbsp;
</td>
</tr>
<tr>
<td style=”width: 274px; height: 22px; text-align: center;”>
&nbsp;<asp:CheckBox ID=”CheckBox1″ runat=”server” Text=”CheckBox Text Align” Font-Bold=”True” />&nbsp;</td>
</tr>
<tr>
<td style=”width: 274px”><asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Left Align Text” Font-Bold=”True” />&nbsp;
<asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”Right Align Text” Font-Bold=”True” /></td>
</tr>
<tr>
<td style=”width: 274px; text-align: center”>
</td>
</tr>
</table>
</td>
</tr>
<tr>
</tr>
</table>

The ASP.Net Checkbox Control Example output is :

Change text align of checkbox control in ASP.Net with C#
Change text align of checkbox control in ASP.Net with C#

STEP 2 – write below code at code behind page of ASP.Net web application.

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

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

The ASP.Net Checkbox Control Example output is :

Change text align of checkbox control in ASP.Net with C#
Change text align of checkbox control in ASP.Net with C#

The ASP.Net Checkbox Control Example output is :

Change text align of checkbox control in ASP.Net with C#
Change text align of checkbox control in ASP.Net with C#

– Hope this ASP.Net Checkbox text align example will help you …

Leave a Reply

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