protected string GenerateHtmlInputFileControl(string lastFileName)
{
var div = new HtmlGenericControl("div");
Controls.Add(div);
if(this.UploaderStyle == AsyncFileUploaderStyle.Modern) {
var bgImageUrl = ToolkitResourceManager.GetImageHref(AjaxControlToolkit.Constants.AsyncFileUploadImage, this);
var style = "background:url(" + bgImageUrl + ") no-repeat 100% 1px; height:24px; margin:0px; text-align:right;";
if(!Width.IsEmpty)
style += "min-width:" + Width.ToString() + ";width:" + Width.ToString() + " !important;";
else
style += "width:355px;";
div.Attributes.Add("style", style);
}
if(!(this.UploaderStyle == AsyncFileUploaderStyle.Modern && IsDesignMode)) {
_inputFile = new HtmlInputFile();
if(!this.Enabled)
_inputFile.Disabled = true;
div.Controls.Add(_inputFile);
_inputFile.Attributes.Add("id", _inputFile.Name.Replace("$", "_"));
if(this.UploaderStyle != AsyncFileUploaderStyle.Modern) {
if(BackColor != Color.Empty)
_inputFile.Style[HtmlTextWriterStyle.BackgroundColor] = ColorTranslator.ToHtml(BackColor);
if(!Width.IsEmpty)
_inputFile.Style[HtmlTextWriterStyle.Width] = Width.ToString();
else
_inputFile.Style[HtmlTextWriterStyle.Width] = "355px";
}
}
if(this.UploaderStyle == AsyncFileUploaderStyle.Modern) {
var style = "opacity:0.0; -moz-opacity: 0.0; filter: alpha(opacity=00); font-size:14px;";
if(!Width.IsEmpty)
style += "width:" + Width.ToString() + ";";
if(_inputFile != null)
_inputFile.Attributes.Add("style", style);
var textBox = new TextBox();
if(!IsDesignMode) {
var div1 = new HtmlGenericControl("div");
div.Controls.Add(div1);
style = "margin-top:-23px;text-align:left;";
div1.Attributes.Add("style", style);
div1.Attributes.Add("type", "text");
div1.Controls.Add(textBox);
style = "height:17px; font-size:12px; font-family:Tahoma;";
} else {
div.Controls.Add(textBox);
style = "height:23px; font-size:12px; font-family:Tahoma;";
}
if(!Width.IsEmpty && Width.ToString().IndexOf("px") > 0)
style += "width:" + (int.Parse(Width.ToString().Substring(0, Width.ToString().IndexOf("px"))) - 107).ToString() + "px;";
else
style += "width:248px;";
if(lastFileName != String.Empty || this._failedValidation) {
if((this.FileBytes != null && this.FileBytes.Length > 0) && (!this._failedValidation)) {
style += "background-color:#00FF00;";
} else {
this._failedValidation = false;
style += "background-color:#FF0000;";
}
textBox.Text = lastFileName;
} else if(BackColor != Color.Empty) {
style += "background-color:" + ColorTranslator.ToHtml(BackColor) + ";";
}
textBox.ReadOnly = true;
textBox.Attributes.Add("style", style);
this._innerTBID = textBox.ClientID;
} else if(IsDesignMode) {
Controls.Clear();
Controls.Add(_inputFile);
}
return div.ClientID;
}