一、简单上传(Simple Upload with Progress)

<CuteWebUI:Uploader ID="ajaxUploader" runat="server" InsertText="上传文件" OnFileUploaded="Uploader_FileUploaded">
</CuteWebUI:Uploader>

protected void Uploader_FileUploaded(object sender, UploaderEventArgs args)
{
  args.MoveTo(args.FileName);
}

二、多文件上传(Selecting multiple files for uploading)

<CuteWebUI:Uploader ID="ajaxUploader" runat="server" MultipleFilesUpload="true" InsertText="上传多个文件" OnFileUploaded="Uploader_FileUploaded">
</CuteWebUI:Uploader> protected void Uploader_FileUploaded(object sender, UploaderEventArgs args)
{
args.MoveTo(args.FileName);
}

三、自定义UI(Simple Upload with Progress (Customizing the UI))

<CuteWebUI:Uploader ID="ajaxUploader" runat="server"  InsertText="上传文件" InsertButtonID="ajaxUploaderInsert" CancelButtonID="ajaxUploaderCancel" ProgressCtrlID="ajaxUploaderProgress" ProgressTextID="ajaxUploaderProgressText" OnFileUploaded="Uploader_FileUploaded">
</CuteWebUI:Uploader>
<asp:Image ID="ajaxUploaderInsert" runat="server" AlternateText="上传" ImageUrl="http://ajaxuploader.com/sampleimages/upload.png" />
<asp:Panel ID="ajaxUploaderProgress" runat="server" BorderColor="Orange" BorderStyle="dashed" BorderWidth="">
<asp:Label ID="ajaxUploaderProgressText" runat="server" ForeColor="Firebrick"></asp:Label>
</asp:Panel>
<asp:Image ID="ajaxUploaderCancel" runat="server" AlternateText="取消上传" ImageUrl="http://ajaxuploader.com/sampleimages/cancel_button.gif" /> protected void Uploader_FileUploaded(object sender, UploaderEventArgs args)
{
args.MoveTo(args.FileName);
}

四、自定义验证(Custom Validation)

<CuteWebUI:Uploader ID="ajaxUploader" runat="server"  InsertText="上传文件" OnFileUploaded="Uploader_FileUploaded">
<ValidateOption AllowedFileExtensions="jpeg,jpg,gif,png" MaxSizeKB="" />
</CuteWebUI:Uploader>

五、添加附件(Uploading multiple files like GMail)

<CuteWebUI:UploadAttachments ID="ajaxUploadAttachments" runat="server" InsertText="上传文件" MultipleFilesUpload="true"></CuteWebUI:UploadAttachments>
<asp:Button ID="BtnDeleteAll" runat="server" Text="全部删除" OnClick="BtnDeleteAll_Click" /> protected void BtnDeleteAll_Click(object sernder, EventArgs args)
{
ajaxUploadAttachments.DeleteAllAttachments();
}

六、(Persist uploaded files through postback)

<CuteWebUI:UploadPersistedFile ID="ajaxUploadPersistedFile" runat="server" InsertText="上传文件" OnFileChanged="ajaxUploadPersistedFile_FileUploaded"></CuteWebUI:UploadPersistedFile>

protected void ajaxUploadPersistedFile_FileUploaded(object sender, PersistedFileEventArgs args)
{
args.MoveTo(args.FileName);
}

七、模拟文件上传(Simulate File Upload)

<CuteWebUI:Uploader ID="ajaxUploader" runat="server" InsertText="上传" OnFileUploaded="ajaxUploader_FileUploaded"></CuteWebUI:Uploader>
<CuteWebUI:UploadAttachments ID="ajaxUploadAttachments" runat="server" InsertText="上传" OnAttachmentAdded="ajaxUploadAttachments_AttachmentAdded"></CuteWebUI:UploadAttachments> protected void ajaxUploader_FileUploaded(object sender,UploaderEventArgs args)
{
using (Stream stream = args.OpenStream())
{
ajaxUploadAttachments.Upload(args.FileSize, args.FileName, stream);
}
} protected void ajaxUploadAttachments_AttachmentAdded(object sender,AttachmentItemEventArgs args)
{
Response.Write(args.Item.FileName);

八、允许最大上传数量(Limit the maximum number of files allowed to upload)

<CuteWebUI:Uploader ID="ajaxUploader" runat="server" InsertText="上传" MultipleFilesUpload="true" OnFileUploaded="ajaxUploader_FileUploaded"></CuteWebUI:Uploader>
<CuteWebUI:UploadAttachments ID="ajaxUploadAttachments" runat="server" OnAttachmentAdded="ajaxUploadAttachments_AttachmentAdded"></CuteWebUI:UploadAttachments> private int GetVisibleItemCount()
{
int count = ;
foreach (AttachmentItem item in ajaxUploadAttachments.Items)
{
count++;
}
return count;
} protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ajaxUploader.InsertButton.Enabled = GetVisibleItemCount() < ;
} protected void ajaxUploader_FileUploaded(object sender, UploaderEventArgs args)
{
if (GetVisibleItemCount() >= )
return;
using (Stream stream = args.OpenStream())
{
ajaxUploadAttachments.Upload(args.FileSize, "ChangeName-" + args.FileName, stream);
}
} protected void ajaxUploadAttachments_AttachmentAdded(object sender, AttachmentItemEventArgs args)
{ }

九、手动开始上传(Start uploading manually)

<script type="text/javascript">
function submitbutton_click() {
var submitButton = document.getElementById('<%=BtnSubmit.ClientID %>');
var uploadObj = document.getElementById('<%=ajaxUploadAttachments.ClientID %>');
if (!window.filesuploaded) {
if (uploadObj.getqueuecount() > ) {
uploadObj.startupload();
} else {
var uploadedcount = parseInt(submitButton.getAttribute("itemcount")) || ;
if (uploadedcount > ) {
return true;
}
alert("Please browse files for uploading");
}
return false;
}
window.filesuploaded = false;
return true;
}
function CuteWebUI_AjaxUploader_OnPostback() {
window.filesuploaded = true;
var submitbutton = document.getElementById('<%=BtnSubmit.ClientID %>');
submitbutton.click();
return false;
}
</script> <CuteWebUI:UploadAttachments ID="ajaxUploadAttachments" runat="server" ManualStartUpload="true" InsertText="上传" OnFileUploaded="ajaxUploadAttachments_FileUploaded"></CuteWebUI:UploadAttachments>
<asp:Button ID="BtnSubmit" runat="server" Text="开始上传" OnClientClick="return submitbutton_click()" /> protected override void OnPreRender(EventArgs e)
{
BtnSubmit.Attributes["itemcount"] = ajaxUploadAttachments.Items.Count.ToString();
base.OnPreRender(e);
}
protected void ajaxUploadAttachments_FileUploaded(object sender, UploaderEventArgs args)
{ }

AjaxUploader使用的更多相关文章

  1. MVC&WebForm对照学习:文件上传(以图片为例)

    原文  http://www.tuicool.com/articles/myM7fe 主题 HTMLMVC模式Asp.net 博客园::首页::  ::  ::  ::管理 5 Posts :: 0 ...

  2. .net ajax式上传文件

    今天在这里介绍一下ajax上传文件.其实也不算是真的使用xmlhttprequest上传,只是使用了iframe实现了无刷新上传而已,最多也只算 是仿ajax上传文件.然而网上关于使用xmlhttpr ...

随机推荐

  1. Linux初学 - 安装及网络配置

    安装版本 CentOS-6.4 虚拟机  vmware workstation 12 配置 网络配置 检查网络设置是否成功 如果网络配置文件检查没有问题,配置完成后网络仍然ping不同 1.检查虚拟机 ...

  2. 用sessionStorage实现页面之间的数据传输

    1.sessionStorage主要含几种方法: //页面A:存放一个简单的字符串 sessionStorage.obj = '123'; //页面B:取到给obj var str = session ...

  3. AndroidManifest常见的设置解析

    AndroidManifest.xml清单文件是每个Android项目所必需的,它是整个Android项目的全局描述文件.AndroidManifest.xml清单文件说明了该应用的名称.所使用的图标 ...

  4. 统计项目的java代码总行数

    http://www.oschina.net/code/snippet_209431_7358 wc -l $(find . -type f -name '*.java')

  5. nodejs+express+jade安装备忘

    安装步骤 1.安装nodejs,比如安装在E:\nodejs. 确保有两个环境变量 用户环境变量:C:\Users\Administrator\AppData\Roaming\npm 系统环境变量:e ...

  6. ios app 提交评审注意事项

    在网络上看到的一个文档是这样写,原文的出处无法确认了 基本要点 ·         不能导致手机故障(比如崩溃或屏幕问题) ·         长时间/过度使用之后反应仍然很快 ·         应 ...

  7. IOS APP 国际化 程序内切换语言实现 不重新启动系统(支持项目中stroyboard 、xib 混用。完美解决方案)

    上篇 IOS APP 国际化(实现不跟随系统语言,不用重启应用,代码切换stroyboard ,xib ,图片,其他资源 介绍了纯代码刷新 实现程序内切换语言. 但效率底下,也存在一些问题.暂放弃. ...

  8. Qt 调试时的错误——Debug Assertion Failed!

    在VS2008中写qt程序时调试出现此问题,但在release模式下就不存在,在网上搜罗了一圈,是指针的问题. 问题是这样的: 需要打开两个文件,文件中数据类型是float,我使用QVector进行保 ...

  9. HQ-SSAO (High-Quality SSAO)

    踩了前前后后无数坑,实现方式都试过了10几种,终于得到这个方案.虽说比不上2015最新的far-field AO,但至少在near/middle-field上,算是state of arts的实现了. ...

  10. mysql 日期对比,varchar类型装换为datetime类型

    select * from tb_gps WHERE str_to_date(intime,'%Y-%m-%d %H:%i:%s') BETWEEN '2013-9-2 14:40:33' and ' ...