Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Dynamically generating CSS classes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 23 Dec 2007 03:56 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Alexey Smirnov - 23 Dec 2007 10:02 GMT
> 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
[quoted text clipped - 11 lines]
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/

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

Example: Button1.Style.Add("width", "100px");
Nathan Sokalski - 23 Dec 2007 17:25 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

On Dec 23, 4:56 am, "Nathan Sokalski" <njsokal...@hotmail.com> 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
[quoted text clipped - 15 lines]
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/

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

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.