Professional Web Applications Themes

Dynamically generating CSS classes - ASP.NET Building Controls

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 ...

  1. #1

    Default Dynamically generating CSS classes

    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
    com
    http://www.nathansokalski.com/


    Nathan Guest

  2. #2

    Default Re: Dynamically generating CSS classes

    On Dec 23, 4:56am, "Nathan Sokalski" <com> wrote: 

    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");
    Alexey Guest

  3. #3

    Default Re: Dynamically generating CSS classes

    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
    com
    http://www.nathansokalski.com/

    "Alexey Smirnov" <com> wrote in message
    news:googlegroups.com...
    On Dec 23, 4:56 am, "Nathan Sokalski" <com> wrote: 

    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 Guest

Similar Threads

  1. Generating classes from an .xsd file
    By Burak in forum ASP.NET Web Services
    Replies: 8
    Last Post: July 14th, 08:29 PM
  2. WSE 2.0- Generating abstract SoapService classes from WSDL
    By raj712k in forum ASP.NET Web Services
    Replies: 0
    Last Post: June 16th, 07:41 PM
  3. Replies: 0
    Last Post: May 4th, 12:31 PM
  4. dynamically generating graphics
    By MJL in forum PERL Miscellaneous
    Replies: 2
    Last Post: September 17th, 07:02 AM
  5. Dynamically generating multi-table SQL
    By J. Gleixner in forum PERL Miscellaneous
    Replies: 7
    Last Post: July 17th, 04:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139