这个控件以前没有用过
只会使用原始的控件进行上传
上传按钮的事件如下:
if (fulDoc.HasFile)
            {
                bool HasType = false;
                bool HasSize = false;
                string typeId = "";
                string fileType = System.IO.Path.GetExtension(fulDoc.FileName).ToString().ToLower();
                DataTable fileTypeList = bllDocumentType.GetList(" DTExtension = '" + fileType + "' ").Tables[0];
                if (fileTypeList.Rows.Count > 0)
                {
                    HasType = true;
                    if (fulDoc.PostedFile.ContentLength / 1024 <= int.Parse(fileTypeList.Rows[0]["DTCapacity"].ToString()))
                    {
                        HasSize = true;
                        typeId = fileTypeList.Rows[0]["DTId"].ToString();
                    }
                }
                if (false == HasType)
                {
                    Response.Write("<script>alert('不合法的文件类型!');</script>");//不合法的文件类型
                    return;
                }
                if (false == HasSize)
                {
                    Response.Write("<script>alert('文件大小超出范围!');</script>");//文件大小超出范围
                    return;
                }
                string saveName = System.IO.Path.GetFileNameWithoutExtension(fulDoc.FileName.ToString());
                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + fileType;
                string filePath = "../UploadFiles/Document/" + System.DateTime.Now.ToString("yyyyMM") + "/" + fileName;
                bool hasDirectory = System.IO.Directory.Exists(Server.MapPath("../UploadFiles/ProfessionProject/" + System.DateTime.Now.ToString("yyyyMM") + "/"));
                if (hasDirectory)
                {
                    fulDoc.SaveAs(Server.MapPath(filePath));
                }
                else
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("../UploadFiles/Document/" + System.DateTime.Now.ToString("yyyyMM") + "/"));
                    fulDoc.SaveAs(Server.MapPath(filePath));
                }
                modelDocument.MIId = bllDocument.CreateId();
                modelDocument.DTId = typeId;
                modelDocument.UserId = typeId;
                modelDocument.MIName = saveName;
                modelDocument.MIPath = filePath;
                bllDocument.Add(modelDocument);                //文件上传完成
                Response.Write("<script>alert('文件上传完成!');</script>");//文件上传完成
            }
            else
            {
                Response.Write("<script>alert('请先选择文件!');</script>");//请先选择文件
                return;
            }
        }
但是用了新的控件就会出错
新控件的名字是fulDoc
求指教

解决方案 »

  1.   

    使用例子
    http://demos.telerik.com/aspnet-ajax/upload/examples/customizingraduploadui/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/upload/examples/clientsidevalidation/defaultcs.aspx
      

  2.   

    就是一个简单的上传功能,如果用自带的FileUpload用上面的方法可以上传成功,但是AJAX的控件都不行,错误是hasfile方法没有,我刚刚在元数据里面没有,我想问一下到底是这个控件没有这个方法,还是我的控件不完整
      

  3.   

    如果你是想提高用户体验 实现无刷新上传建议使用Jqaury+flash -----推荐插件:Uploadify或者swfupload
      

  4.   

    Uploadify为什吗Flash按钮显示不出来