css from server-side code

  1. #1

    css from server-side code

    Hello,

    is it possible to apply a css style via code behind (v0.8.2) like happens with asp.net controls?

    I've tried with:

    Panel_1.Bodystyle = "background-color:#ff0000 !important, color:#ff0000, font-size:small"
    but it doesn't works.

    Thanks.
  2. #2
    Hi,

    You should separate style items with a semi-colon, not a common.

    Example

    this.Panel1.BodyStyle = "background-color:#ff0000 !important; color:#ff0000; font-size:small";
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Hi,

    I tried that but I get the same runtime error in a dynamic file called "coolite.axd?v=2648".
  4. #4
    Hi,

    "!important" is wrong thing for inline style. Please use this key word in css classes only.

    So, it works fine without this word.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
             this.Panel1.BodyStyle = "background-color:#ff0000 !important; color:#ffffff; font-size:small;";
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Coolite 0.8.X Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ScriptManager runat="server" />
        <ext:Panel 
            ID="Panel1" 
            runat="server" 
            Width="200" 
            Height="200" 
            Html="Hello world!" />
        </form>
    </body>
    </html>
    If you really need to use "!important" to get that you need please use a respective css class and set it as a value of .BodyCls property.

Similar Threads

  1. Replies: 0
    Last Post: May 10, 2012, 12:38 PM
  2. I need this code in Server Side
    By walle in forum 1.x Help
    Replies: 1
    Last Post: Jul 20, 2011, 6:58 PM
  3. Javascript to server side code
    By Birgit in forum 1.x Help
    Replies: 0
    Last Post: Sep 24, 2010, 7:56 AM
  4. Couldn't get my Hidden Value at server-side code.
    By jeeshenlee in forum 1.x Help
    Replies: 1
    Last Post: May 21, 2010, 3:47 AM
  5. Replies: 0
    Last Post: May 17, 2010, 3:07 AM

Tags for this Thread

Posting Permissions