Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Dynamically generating CSS classes

Reply
Thread Tools

Dynamically generating CSS classes

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      12-23-2007
There are many situations in which we want to assign certain styles with
multiple CSS properties to a control, quite often the same ones for multiple
controls. Sometimes these styles must be dynamically generated just like the
other parts of the control. Because of the need to have the style
dynamically generated, a static CSS class is not appropriate. I would like
to know if anybody knows of a good way to add a CSS class from within a
custom control. I would like to do this so that I can simply assign the CSS
class to the control. My reason for wanting to do this is so that rather
than have a bunch of controls with style attributes that are huge, they just
have a simple class attribute. This would significantly decrease the
download size for controls that use the same style multiple times. If
anybody knows of a good way to do this, please let me know. Thanks.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      12-23-2007
On Dec 23, 4:56*am, "Nathan Sokalski" <(E-Mail Removed)> wrote:
> There are many situations in which we want to assign certain styles with
> multiple CSS properties to a control, quite often the same ones for multiple
> controls. Sometimes these styles must be dynamically generated just like the
> other parts of the control. Because of the need to have the style
> dynamically generated, a static CSS class is not appropriate. I would like
> to know if anybody knows of a good way to add a CSS class from within a
> custom control. I would like to do this so that I can simply assign the CSS
> class to the control. My reason for wanting to do this is so that rather
> than have a bunch of controls with style attributes that are huge, they just
> have a simple class attribute. This would significantly decrease the
> download size for controls that use the same style multiple times. If
> anybody knows of a good way to do this, please let me know. Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/


There is a Style Class that represents the style of a web server
control
http://msdn2.microsoft.com/en-us/lib...ols.style.aspx

Example: Button1.Style.Add("width", "100px");
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      12-23-2007
That does not create a CSS class, it simply adds CSS properties to the
control's style attribute. I am looking to create a CSS class that could be
used the same way as the following:

<style type="text/css">
.myclass{width:100px;}
</style>

Any classes that would be generated would have more CSS properties than
this, but the point is to be able to use the class attribute rather than the
style attribute.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Dec 23, 4:56 am, "Nathan Sokalski" <(E-Mail Removed)> wrote:
> There are many situations in which we want to assign certain styles with
> multiple CSS properties to a control, quite often the same ones for
> multiple
> controls. Sometimes these styles must be dynamically generated just like
> the
> other parts of the control. Because of the need to have the style
> dynamically generated, a static CSS class is not appropriate. I would like
> to know if anybody knows of a good way to add a CSS class from within a
> custom control. I would like to do this so that I can simply assign the
> CSS
> class to the control. My reason for wanting to do this is so that rather
> than have a bunch of controls with style attributes that are huge, they
> just
> have a simple class attribute. This would significantly decrease the
> download size for controls that use the same style multiple times. If
> anybody knows of a good way to do this, please let me know. Thanks.
> --
> Nathan Sokalski
> (E-Mail Removed)://www.nathansokalski.com/


There is a Style Class that represents the style of a web server
control
http://msdn2.microsoft.com/en-us/lib...ols.style.aspx

Example: Button1.Style.Add("width", "100px");


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS classes within classes Mark Smith Javascript 3 12-22-2008 02:46 PM
Dynamically generating CSS classes Nathan Sokalski ASP .Net 2 12-23-2007 05:25 PM
Dynamically generating classes? Jonas Galvez Ruby 14 09-28-2005 03:55 PM
Generating base classes from sql server Poppy ASP .Net 1 07-30-2004 10:45 AM
Can I using reflection to get all child classes or classes undera package dynamically? Carfield Yim Java 1 05-31-2004 05:33 PM



Advertisments