[CLOSED] Label properties ForeColor and BackColor on codebehind

  1. #1

    [CLOSED] Label properties ForeColor and BackColor on codebehind

    Hello while migrating I have just noticed that ForeColor and BackColor does not seem to work on codebehind.
    Here is an example which shows it. In the breaking changes there is no mention about it. Is a bug or I need to set the colors in a different way?

    Here is an example code, nor the background color nor the foreground color are displayed

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
            // Build Window to hold everything
            Window win = new Window();
            win.ID = "Window1";
            win.Layout = LayoutType.Form.ToString();
            win.Title = "Test Controls";
            win.Icon = Icon.Application;
            win.Width = Unit.Pixel(600);
            win.Height = Unit.Pixel(350);
            win.Border = false;
            win.Collapsible = true;
            win.Plain = true;
    
            Ext.Net.Label webLabel=new Ext.Net.Label();
            webLabel.Text="This label should be red with green background";
            
            //foreground color should be red and backgroud green
            
            webLabel.ForeColor=System.Drawing.Color.Red;
            webLabel.BackColor=System.Drawing.Color.Green;
            
            win.Items.Add(webLabel);
            
    
            // Add Window to Form
            this.PlaceHolder1.Controls.Add(win);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Simple BorderLayout - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <h1>Test</h1>
        
        <ext:Button 
            ID="Button1" 
            runat="server" 
            Text="Show Window" 
            Icon="Application">
            <Listeners>
                <Click Handler="#{Window1}.show();" />
            </Listeners>    
        </ext:Button>
        
        <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
    </body>
    </html>
    Last edited by Daniil; Jan 14, 2015 at 9:05 AM. Reason: [CLOSED]
  2. #2
    SOLVED.

    These properties have no effect I can change the colors using the StyleSpec property.

    This other example works.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
    
            // Build Window to hold everything
            Window win = new Window();
            win.ID = "Window1";
            win.Layout = LayoutType.Form.ToString();
            win.Title = "Test Controls";
            win.Icon = Icon.Application;
            win.Width = Unit.Pixel(600);
            win.Height = Unit.Pixel(350);
            win.Border = false;
            win.Collapsible = true;
            win.Plain = true;
    
            Ext.Net.Label webLabel=new Ext.Net.Label();
             webLabel.Text="This label should be red with green background";
            
            //foreground color should be red and backgroud green
            string textstyle=string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                              "color:rgb({0},{1},{2});",
                                              System.Drawing.Color.Red.R,
                                              System.Drawing.Color.Red.G,
                                              System.Drawing.Color.Red.B);
              
            textstyle+=string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                              "background-color:rgb({0},{1},{2});",
                                              System.Drawing.Color.Green.R,
                                              System.Drawing.Color.Green.G,
                                              System.Drawing.Color.Green.B);
                                              
            webLabel.StyleSpec=textstyle;
            
            win.Items.Add(webLabel);
            
    
            // Add Window to Form
            this.PlaceHolder1.Controls.Add(win);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Simple BorderLayout - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <h1>Test</h1>
        
        <ext:Button 
            ID="Button1" 
            runat="server" 
            Text="Show Window" 
            Icon="Application">
            <Listeners>
                <Click Handler="#{Window1}.show();" />
            </Listeners>    
        </ext:Button>
        
        <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
    </body>
    </html>
  3. #3
    Hi @jcanton,

    Yes, those properties are not supported.
    http://forums.ext.net/showthread.php?41671
  4. #4
    I'll add a little additional information, those properties are inherited from the ASP.NET WebControl base class, and there is no way to hide/remove them from Intellisense. We just ignore them.
    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] BackColor,ForeColor not work
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2015, 3:22 AM
  2. [CLOSED] Properties missing on the codebehind
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 28, 2011, 5:33 PM
  3. Replies: 2
    Last Post: Aug 10, 2010, 4:27 PM
  4. Changing Label ForeColor
    By virus in forum 1.x Help
    Replies: 2
    Last Post: Sep 21, 2009, 9:52 AM
  5. setting Label cssStyle or color in codebehind
    By madhugumma in forum 1.x Help
    Replies: 0
    Last Post: Jun 19, 2009, 4:29 AM

Posting Permissions