RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > ASP/VbScript >

颜色的转换

来源:Blog 作者:未知 时间:2005-08-26 Tag: 点击:

上回我回复的看椰子林DotNet的天空-----ASP.NET组件编程step by step-------------------
# 回复:有点小BUG
//以下将颜色值转化成十六进制表示
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;
-----------------------------------

其实以下代码可以换成一行代码就搞定--------------------
//以下将颜色值转化成十六进制表示
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 + "')";
--------改成-------------------------
this.textBox.Attributes.Add("onmouseover","ltmouseover(this,'" + ColorTranslator.ToHtml(this._mouseoverColor) + "')");

简单吧!无意中发现的!因为我想想MS不可能把一个颜色转换要自己写得这么麻烦。


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
热点关注
相关文章