Todesengel
New Member
How do you set the width of a textbox control with code behind?<BR>(txtTemp is the name of our textbox control.)<BR><BR>1. First we tried:<BR><BR>Dim y As Integer = 10<BR>txtTemp.Width = y<BR><BR>This throws a compile error with converting to System.Web.UI.WebControls.Unit.<BR><BR>2. Next, we tried:<BR><BR>Dim y As Integer = 10<BR>Dim x As System.Web.UI.WebControls.Unit<BR>x.Pixel(y)<BR>txtTemp.Width = x<BR><BR>This doesn't throw an error, but it doesn't set the width. Anyone done this? Thanks.<BR><BR>Wendy Attenberger<BR>XiTech<BR>Hi, <BR><BR>The property is "Columns" instead of "Width". <BR><BR>Try:<BR><BR>txtTemp.Columns = x<BR>Thanks. That's what I was looking for! <BR><BR>I did finally get the syntax right on the width with pixels, but what I really wanted was the columns so it rendered the "normal" size="5" attribute name pair. Thanks!<BR><BR>The following worked...<BR>txtTemp.Width = Unit.Pixel(5)<BR><BR>but what we really wanted was:<BR>txtTemp.Columns = 5