How to change TextBox width programmatically in ASP.NET

change TextBox width programmatically in ASP.Net C#

- In this ASP.Net post we will discuss about  How to Change Width of TextBox Control Programmatically  in ASP,.Net C#.

- Here, we need to Design the ASP.Net Page with One TextBox Control along with the Two (2) Button  Control.
- The ASP.Net Design Code is below :

write below code in head tag:-

<body>
<form id=”form1″ runat=”server”>
<table style=”width: 304px”>
<tr>
<td style=”width: 100px; text-align: right”>
TextBox :</td>
<td colspan=”2″ style=”text-align: left”>
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>
</tr>
<tr>
<td style=”width: 100px; height: 26px”>
</td>
<td colspan=”2″ style=”height: 26px; text-align: left”>
&nbsp;<asp:Button ID=”Button1″ runat=”server” OnClick=”Button1_Click” Text=”Widht 100″ />
<asp:Button ID=”Button2″ runat=”server” OnClick=”Button2_Click” Text=”Widht 180″ /></td>
</tr>
</table>
</form>
</body>
write below code for width 100:-

protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Width = 100;
    }

- Below figure show the TextBox Control width = 100, when we clicked the First Button Width 100.

write below code for width 180:-

protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Width = 180;
    }

Set TextBox width in ASP.Net

Set TextBox width in ASP.Net

- Below figure show the TextBox Control width = 180, when we clicked the Second Button Width 180.

Change TextBox width in ASP.Net

Change TextBox width in ASP.Net

- In above post we get the ideas about How to change width of TextBox Control Programmtically in ASP.Net.

- We can do this thing without prgrammatically Just SET width Property of the TextBox Control.

- I hope you will like this ASP.Net TextBox Example Tutorials.

Leave a Reply

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

5 + 2 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">