日期:2014-05-17 浏览次数:20400 次
<form id="form1" runat="server">
<div>
<input name="datepicker" type="text" id="datepicker">
<asp:TreeView ID="TreeView1" runat="server">
<Nodes><asp:TreeNode Value="新建文件夹" Text="新建文件夹"></asp:TreeNode></Nodes>
</asp:TreeView>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="上传" OnClick="Button1_Click" />
</div>
</form>
protected void Button1_Click(object sender, EventArgs e)
{
if (!FileUpload1.HasFile)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('选择上传文件');</script>");
}
else
{
#region 注释
////验证上传文件大小
//if (FileUpload1.FileContent.Length > 2 * 1024 * 1024
------解决方案--------------------
FileUpload1.FileContent.Length <= 0)
//{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('上传文件大小不正确');</script>");
// return;
//}