specify the width of dynamically generated textboxes

S

susie

I have the following code to generate textbox
dynamically. How can I specify all the textbox with to 50?
For i = 0 To e.Item.Controls.Count-1
Try
If (e.Item.Controls(i).Controls
(0).GetType().ToString()
= "System.Web.UI.WebControls.TextBox") Then
Dim tb As TextBox
tb = e.Item.Controls(i).Controls(0)
tb.Text = Server.HtmlDecode
(tb.Text)
End If
Catch

End Try
Next

Thanks a lot.
 
V

Victor Garcia Aprea [MVP]

Hi Susie,

Do you mean 50 chars max or 50 pixels in lengh?
[C#]
TextBox1.Style["width"]="50px"; // this will set the width to 50 pixels
TextBox1.MaxLength = 50; // this will set the max # of allowed chars to 50

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx

To contact me remove 'NOSPAM'. Please post all questions to the newsgroup

and not by private mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top