'System.Drawing.Color.Red.get' cannot be accessed

Posted on 2006-04-12
Last Modified: 2012-06-27
i have converted code from vb to c# and im getting this error, how do i get rid of this:

 public void ControlToHighlight(string ControlType, string ControlId)
        TextBox oControlTextbox;
        DropDownList oControlDropDown;
        CheckBoxList oCheckBoxList;
        RadioButtonList oRadioButtonList;
        Label oLabel;
        Panel oPanel;
        if (ControlType.Length > 0)
            if (ControlType == "textbox")
                oControlTextbox = ((TextBox)(FindControl(ControlId)));
                if ((!(oControlTextbox == null)))
                    oControlTextbox.BackColor = oControlTextbox.BackColor.Red;   <<<<<<<<error
                    oControlTextbox.ForeColor = oControlTextbox.ForeColor.White; <<<<<<<<error

error message is:

Error      1      Static member 'System.Drawing.Color.Red.get' cannot be accessed with an instance reference; qualify it with a type name instead      App_Code\webPagebase.cs      49      50      
Question by:madina1
    LVL 39

    Accepted Solution

    try changing

    oControlTextbox.BackColor = oControlTextbox.BackColor.Red;   <<<<<<<<error
    oControlTextbox.ForeColor = oControlTextbox.ForeColor.White; <<<<<<<<error


    oControlTextbox.BackColor = System.Drawing.Color..Red;  
    oControlTextbox.ForeColor = System.Drawing.Color..White;

    Author Comment

    before i post it, i did the exact thing and then i thought im not doing correct so that correct?
    LVL 39

    Expert Comment

    yes its correct, try it and see the results

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now