asp.net控件FileUpload

最近在用FileUpload做上传下载业务,弹出页面FileUpload不能回传,然后通过UpdatePanel实现post,可后台判断是否有上传文件的时候发现HasFile判断不准确,不知道是微软控件的问题还是我的页面缓存的问题,最后勉强实现功能,前台和后台关键代码如下

前台:

<asp:UpdatePanel runat="server" ID="upnAddNotices">
<ContentTemplate>
<asp:FileUpload ID="fuFileUrl" runat="server" Width="400px" EnableViewState="false" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="lbtnSave" />
</Triggers>
</asp:UpdatePanel>

 

 

后台:

if (CMMUtils.IsNullOrEmpty(this.txtExamRoomEdition.Text.Trim()))
{
msg = "大厅版本名称不能为空!";
this.txtExamRoomEdition.Focus();
}
else if (CMMUtils.IsNullOrEmpty(this.fuFileUrl.FileName.Trim()))
{
msg = "必须选择大厅安装文件!";
this.fuFileUrl.Focus();
}
//else if (!this.fuFileUrl.HasFile)
//{
// msg = "必须选择大厅安装文件!";
// this.fuFileUrl.Focus();
//}

这个“this.fuFileUrl.HasFile”判断不准确,所以改用this.fuFileUrl.FileName做判断 ,不知道为什么

 

posted on 2013-03-07 14:25  青山依旧在  阅读(398)  评论(0)    收藏  举报