原因:FileUpload绑定的change事件不会执行到,而应绑定fileselected事件。
解决方案:
修改 FileUpload.cs (红色为添加的代码)
protected override void OnFirstPreRender()
{
base.OnFirstPreRender();
AddStartupAbsoluteScript("X.form_upload_file=true;");
if (!String.IsNullOrEmpty(ButtonText))
{
OB.AddProperty("buttonText", ButtonText);
}
if (ButtonOnly)
{
OB.AddProperty("buttonOnly", true);
}
if (AutoPostBack)
{
OB.Listeners.AddProperty("fileselected", JsHelper.GetFunction(GetPostBackEventReference()), true);
}
string resolvedIconUrl = IconHelper.GetResolvedIconUrl(ButtonIcon, ButtonIconUrl);
if (!String.IsNullOrEmpty(resolvedIconUrl))
{
OptionBuilder buttonOB = new OptionBuilder();
buttonOB.AddProperty("cls", " x-btn-text-icon");
buttonOB.AddProperty("icon", resolvedIconUrl);
OB.AddProperty("buttonCfg", buttonOB);
}
//if (TextMode != TextMode.Text)
//{
// OB.AddProperty("inputType", TextModeHelper.GetName(TextMode));
//}
string jsContent = String.Format("var {0}=new Ext.ux.form.FileUploadField({1});", XID, OB.ToString());
AddStartupScript(jsContent);
}
#region IPostBackDataHandler Members
/// <summary>
/// 处理回发数据
/// </summary>
/// <param name="postDataKey">回发数据键</param>
/// <param name="postCollection">回发数据集</param>
/// <returns>回发数据是否改变</returns>
public override bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
if (Enabled)
{
return true;
}
return false;
}
/// <summary>
/// 触发回发数据改变事件
/// </summary>
public override void RaisePostDataChangedEvent()
{
OnTextChanged(EventArgs.Empty);
}
#endregion
|