CssClass

S

shapper

Hello,

On a class I am defining the CssClass of a control at runtime.
However, I would also like to create the CssClass at runtime. Is this
possible?

Something like:
Dim myCssClass="clear:both; color: #FFFFFF"
MyControl.CssClass = myCssClass

Thanks,
Miguel
 
B

bruce barker

CssClass is the html class attribute and should be the name of a style
class, not a style command.

you can render the style commands at runtime.

-- bruce (sqlwork.com)
 
G

Guest

Sure:

Dim myCssClassName As String ="myCSS"
Dim myCssClassDefinition As String = "clear:both; color: #FFFFFF"
Dim ltrl As Literal = New Literal
ltrl.Text = String.Format("<{0} type='text/css'>.{1} {{{2}}}</{0}>",
"style", myCssClassName , myCssClassDefinition)
Me.Page.Header.Controls.Add(ltrl)

' and then assign your class to controls:
MyControl.CssClass = myCssClassName
 

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,771
Messages
2,569,587
Members
45,097
Latest member
RayE496148
Top