Programatically adding a style

  • Thread starter Ken Cox [Microsoft MVP]
  • Start date
K

Ken Cox [Microsoft MVP]

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]
 
J

jsh02_nova

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
 
J

jsh02_nova

That was it, got that cat skinned!
Thanks Ken

v/r
-jsh

Ken Cox said:
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 said:
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
 

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

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top