specify the width of dynamically generated textboxes

Discussion in 'ASP .Net Web Controls' started by susie, Oct 22, 2003.

  1. susie

    susie Guest

    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.
    susie, Oct 22, 2003
    #1
    1. Advertising

  2. 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.
    "susie" <> wrote in message
    news:049601c398d4$7b80c070$...
    > 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.
    Victor Garcia Aprea [MVP], Oct 23, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will Lastname
    Replies:
    5
    Views:
    439
    Will Lastname
    Sep 22, 2005
  2. AndrewF
    Replies:
    1
    Views:
    744
    Bruce Barker
    Oct 10, 2005
  3. =?Utf-8?B?TWlrZQ==?=

    generated textboxes in Ajax UpdatePanel

    =?Utf-8?B?TWlrZQ==?=, Sep 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    1,588
    =?Utf-8?B?TWlrZQ==?=
    Sep 19, 2007
  4. Replies:
    0
    Views:
    915
  5. Nick
    Replies:
    1
    Views:
    203
Loading...

Share This Page