Conversion of colors

Source: Internet
Author: User
Tags tostring
Convert last time I replied look at Coconut Grove dotnet Sky-----asp.net component Programming Step by Step-------------------
# reply: A little bug
The following converts a color value into a hexadecimal representation
String r,g,b;
R = (Convert.ToInt32 (THIS._BACKGROUNDCOLOR.R)). ToString ("X");
G = (Convert.ToInt32 (THIS._BACKGROUNDCOLOR.G)). ToString ("X");
B = (Convert.ToInt32 (this._backgroundcolor.b)). ToString ("X");
if (r.length==1) R = "0" + R;
if (g.length==1) g = "0" + G;
if (b.length==1) b = "0" + B;
-----------------------------------

In fact, the following code can be replaced by one line of code--------------------
The following converts a color value into a hexadecimal representation
String r,g,b;

R = (Convert.ToInt32 (THIS._BACKGROUNDCOLOR.R)). ToString ("X");

G = (Convert.ToInt32 (THIS._BACKGROUNDCOLOR.G)). ToString ("X");

B = (Convert.ToInt32 (this._backgroundcolor.b)). ToString ("X");

if (r.length==1)
r = "0" + R;
if (g.length==1)
g = "0" + G;
if (b.length==1)
b = "0" + B;


Table t= (table) controls[i];

T.attributes.add ("id", T.clientid);

this.textbox.attributes["onfocus" "]=" Ltmouseover ("+t.clientid+", "" + "#" + R + G + B + "')";
--------changed to-------------------------
THIS.TEXTBOX.ATTRIBUTES.ADD ("onmouseover", "Ltmouseover" (This, ' "+ colortranslator.tohtml (this._mouseovercolor) +" " )");

It's easy! I found it by accident! Because I think MS can not put a color conversion to write their own so trouble.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.