/// <summary> /// Sets the color. /// </summary> /// <param name="args">The args.</param> protected void SetColorClassic(ClientPipelineArgs args) { if (args.IsPostBack && args.HasResult) { int oleColor; if (int.TryParse(args.Result, out oleColor)) { var colorCode = String.Concat("#", StringUtil.Right("000000" + MainUtil.IntToHex(oleColor), 6)); if (Value != colorCode) { SetModified(); SetValue(colorCode); } } } else { var script = new StringBuilder(); script.Append("(function(){"); script.Append("var helper=document.getElementById('dlgHelper');"); script.Append("if(helper!=null){"); script.Append("try{"); script.Append("return helper.ChooseColorDlg("); Match iniColor; if (!String.IsNullOrEmpty(GetValue()) && (iniColor = Regex.Match(GetValue(), @"(?=^\#(?<small>[0-9a-fA-F]{3})$)|(?=^\#(?<full>[0-9a-fA-F]{6})$)")).Success) { if (String.IsNullOrEmpty(iniColor.Groups["full"].Value)) { string full = Regex.Replace(iniColor.Groups["small"].Value, "(?<red>[0-9a-fA-F])(?<green>[0-9a-fA-F])(?<blue>[0-9a-fA-F])", "${red}${red}${green}${green}${blue}${blue}"); script.Append("\'"); script.Append(full); script.Append("\'"); } else { script.Append("\'"); script.Append(iniColor.Groups["full"].Value); script.Append("\'"); } } script.Append(");"); // end ChooseColorDlg script.Append("}"); // ent try script.Append("catch(err){"); script.Append("alert(\"Sorry, your browser does not support HtmlDlgSafeHelper, please use IE>=6 version.\");"); script.Append("}"); // end catch script.Append("}"); // end if script.Append("})"); // end function script.Append("();"); // call function SheerResponse.Eval(script.ToString()).Attributes["response"] = "1"; args.WaitForPostBack(); } }