Programatically adding a style

Discussion in 'ASP .Net Web Controls' started by Ken Cox [Microsoft MVP], Jun 3, 2004.

  1. Hi JSH,

    This code might be what you're after:

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Dim tb As New TextBox
    tb.TextMode = TextBoxMode.MultiLine
    tb.Rows = 1
    tb.Style.Add("OVERFLOW", "hidden")
    PlaceHolder1.Controls.Add(tb)
    End Sub

    It produces this as the Style for the texbox:

    style="OVERFLOW:hidden;"

    Does this help?

    Ken
    Microsoft MVP [ASP.NET]


    "jsh02_nova" <> wrote in message
    news:...
    > Does anybody know if it is possible to add a particular CSS style
    > attribute
    > dynamically at runtime to a webcontrol other than setting the property
    > values provided in the Style type? I would like to add "OVERFLOW:
    > hidden",
    > but Style doesn't have this property.
    >
    > e.i.,
    > Dim tb As New TextBox
    >
    > tb.TextMode = TextBoxMode.MultiLine
    > tb.Rows = 1
    > 'nice try :(
    > Dim newStyle = New Style("OVERFLOW: hidden")
    > tb.ApplyStyle(newStyle)
    >
    > thx
    > -jsh
    >
    >
     
    Ken Cox [Microsoft MVP], Jun 3, 2004
    #1
    1. Advertising

  2. Ken Cox [Microsoft MVP]

    jsh02_nova Guest

    Does anybody know if it is possible to add a particular CSS style attribute
    dynamically at runtime to a webcontrol other than setting the property
    values provided in the Style type? I would like to add "OVERFLOW: hidden",
    but Style doesn't have this property.

    e.i.,
    Dim tb As New TextBox

    tb.TextMode = TextBoxMode.MultiLine
    tb.Rows = 1
    'nice try :(
    Dim newStyle = New Style("OVERFLOW: hidden")
    tb.ApplyStyle(newStyle)

    thx
    -jsh
     
    jsh02_nova, Jun 4, 2004
    #2
    1. Advertising

  3. Ken Cox [Microsoft MVP]

    jsh02_nova Guest

    That was it, got that cat skinned!
    Thanks Ken

    v/r
    -jsh

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:%...
    > Hi JSH,
    >
    > This code might be what you're after:
    >
    > Private Sub Page_Load _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) _
    > Handles MyBase.Load
    > Dim tb As New TextBox
    > tb.TextMode = TextBoxMode.MultiLine
    > tb.Rows = 1
    > tb.Style.Add("OVERFLOW", "hidden")
    > PlaceHolder1.Controls.Add(tb)
    > End Sub
    >
    > It produces this as the Style for the texbox:
    >
    > style="OVERFLOW:hidden;"
    >
    > Does this help?
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    >
    >
    > "jsh02_nova" <> wrote in message
    > news:...
    > > Does anybody know if it is possible to add a particular CSS style
    > > attribute
    > > dynamically at runtime to a webcontrol other than setting the property
    > > values provided in the Style type? I would like to add "OVERFLOW:
    > > hidden",
    > > but Style doesn't have this property.
    > >
    > > e.i.,
    > > Dim tb As New TextBox
    > >
    > > tb.TextMode = TextBoxMode.MultiLine
    > > tb.Rows = 1
    > > 'nice try :(
    > > Dim newStyle = New Style("OVERFLOW: hidden")
    > > tb.ApplyStyle(newStyle)
    > >
    > > thx
    > > -jsh
    > >
    > >

    >
     
    jsh02_nova, Jun 5, 2004
    #3
    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. Michelle Stone

    Datagrid, adding a row programatically

    Michelle Stone, Oct 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    19,749
    Saravana [MVP]
    Oct 18, 2003
  2. PJ6
    Replies:
    4
    Views:
    492
    Patirck Ige
    Oct 7, 2005
  3. Replies:
    0
    Views:
    417
  4. Ken Varn
    Replies:
    0
    Views:
    479
    Ken Varn
    Apr 26, 2004
  5. technoGirl
    Replies:
    8
    Views:
    702
    marss
    Jan 3, 2007
Loading...

Share This Page