Solved

reset button background color - c#

Posted on 2014-07-29
7
1,680 Views
Last Modified: 2014-07-29
I have used the following to reset button color:

Note that btn12 has no settings (its blank and gets its style from a css file). So instead of: btn.BackColor = ""; or btn.BackColor = null; I have used btn.BackColor = btn12.BackColor;

At line 14 (var c = btn12.BackColor;) no settings for btn12 reads c="{Name=0, ARGB(0,0,0,0)}", and
At line 15 (c = btn.BackColor;) the settings for the current btn reads c="{Name=Orange, ARGB(255,255,165,0)}",

Question: Can I then replace line 5 (btn.BackColor = btn12.BackColor;) with:

btn.BackColor = "{Name=0, ARGB(0,0,0,0)}";

Because neither of btn.BackColor = ""; or btn.BackColor = null; work.

Thank you.
 int i;
       for (i = 1; i < 11; i++)
        {
            Button btn = (Button)this.FindControl("btn" + i.ToString());
           btn.BackColor = btn12.BackColor;
        }


        if (Session["pressedButton"] != null)
        {
            string strButton = Session["pressedButton"].ToString();
            Button btn = (Button)this.FindControl(strButton);
            btn.BackColor = Color.Orange;
            var c = btn12.BackColor;
            c = btn.BackColor;
        }

Open in new window

0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40227274
You would use something of this sort, or System.Drawing.Color.Orange if you want to reference by name.
btn .BackColor = System.Drawing.Color.FromArgb(0, 0, 0, 0);

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40227327
Hi Randy,

This gives black background to the buttons. It doesn't clear its backcolor property. I understand your logic but there has to be something else.

{Name=0, ARGB(0,0,0,0)}   <-- name argument is not set to zero in your code and I don't know how this part is done.

Mike
0
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40227346
that will give A black, rgb 000 is black if your trying to clear it, (make it transparent)
btn.BackColor = System.Drawing.Color.Transparent;

Open in new window

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40227365
btn.BackColor = System.Drawing.Color.Transparent;

makes it transparent. It is not the same as nothing set.

Therefore, transparent setting doesn't allow css setting work. It just makes the buttons transparent.

Mike
0
 
LVL 21

Accepted Solution

by:
Randy Poole earned 500 total points
ID: 40227409
Hmm.
You can also try one of these:
btn.BackColor = System.Drawing.Color.FromName("0");

Open in new window

or
btn.BackColor = System.Drawing.Color.Empty;

Open in new window

or
btn.BackColor = System.Drawing.Color.FromName(null);

Open in new window

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40227460
First two work okay:

btn.BackColor = System.Drawing.Color.FromName("0");
btn.BackColor = System.Drawing.Color.Empty;


but not the last:
btn.BackColor = System.Drawing.Color.FromName(null);

Thanks,

Mike
0
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40227583
NP
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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