Reputation: 3499
How to set align center for an <asp:TextBox>
control in an ASP.NET Web Application?
Upvotes: 30
Views: 130375
Reputation: 34909
Add the css styling text-align: center
to the control.
Ideally you would do this through a css class assigned to the control, but if you must do it directly, here is an example:
<asp:TextBox ID="myTextBox" runat="server" style="text-align: center"></asp:TextBox>
Upvotes: 62
Reputation: 3531
You can use:
<asp:textbox id="textBox1" style="text-align:center"></asp:textbox>
Or this:
textbox.Style["text-align"] = "center"; //right, left
Upvotes: 12
Reputation: 8706
To center align text
input[type='text'] { text-align:center;}
To center align the textbox in the container that it sits in, apply text-align:center to the container.
Upvotes: 1