首页 > 代码库 > rad 上传空间二次开发指导书

rad 上传空间二次开发指导书

1 适用范围
本组件rad组件包的组件,支持.NET Framework 1.1 和 2.0,B/S架构的应用系统。
支持IE、FireFox等多种浏览器。

2 控件功能
 点击有上传进度条上传
  
 
优点:
1 有ajax的上传实时进度条。对大文件上传
2 对上传文件的大小、种类、上传后的目录保存都封装好了,配制几个属性就行
2.1 高度封装
结构比较简单,已经封装

2.2 使用方法
1 首先安 as装r.a.d UPLOAD 控件,或者安装整个r.a.d control包
2 在开发环境引用这个组件 RadUpload.Net.dll
 3 可以直接在工具栏里往界面拖了
 
 最简单的使用
<%@ Register TagPrefix="radU" Namespace="Telerik.WebControls" Assembly="RadUpload.Net2" %>
1. 
<radU:RadUpload ID="upload1" Runat="server">
</radU:RadUpload>

2.3 要点
1 上传大文件,可以在system.web里配置
<configuration>
<system.web>
    <httpRuntime maxRequestLength="10000" />
  </system.web>
</configuration>

3 上传进度条
<radu:radupload id="RadUpload1" runat="server" />
<radu:radprogressarea id="RadProgressArea1" runat="server" />
<radu:radprogressmanager id="RadProgressManager1" runat="server" />
<asp:button id="Button1" runat="server" text="Submit" />

private void LooongMethodWhichUpdatesTheProgressContext(UploadedFile file)
{
   const int total = 100;

   RadProgressContext progress = RadProgressContext.Current;
   for (int i=0; i<total; i++)
   {
      progress["SecondaryTotal"] = total.ToString();
      progress["SecondaryValue"] = i.ToString();
      progress["SecondaryPercent"] = i.ToString();
      progress["CurrentOperationText"] = file.GetName() + " is being processed...";

      if (!Response.IsClientConnected)
      {
          //Cancel button was clicked or the browser was closed, so stop processing
          break;
      }

      //Stall the current thread for 0.1 seconds
      System.Threading.Thread.Sleep(100);
   }
}

private void Button1_Click(object sender, System.EventArgs e)
{
   UploadedFile file = RadUploadContext.Current.UploadedFiles[File1.UniqueID];
   if (file != null)
   {
      LooongMethodWhichUpdatesTheProgressContext(file);
   }
}

protected void Page_Load(Object sender, System.EventArgs e)
{
   if (!IsPostBack)
   {
      //Do not display SelectedFilesCount progress indicator.
      RadProgressArea1.ProgressIndicators = ProgressIndicators.CurrentFileName |
         ProgressIndicators.FilesCount |
         ProgressIndicators.FilesCountBar |
         ProgressIndicators.FilesCountPercent |
         ProgressIndicators.RequestSize |
         ProgressIndicators.TimeElapsed |
         ProgressIndicators.TimeEstimated |
         ProgressIndicators.TotalProgress |
         ProgressIndicators.TotalProgressBar |
         ProgressIndicators.TotalProgressPercent |
         ProgressIndicators.TransferSpeed;

      RadProgressArea1.Localization["UploadedFiles"] = "Processed ";
      RadProgressArea1.Localization["TotalFiles"] = "";
      RadProgressArea1.Localization["CurrentFileName"] = "File: ";

      RadProgressContext progress = RadProgressContext.Current;
      //Prevent the secondary progress from appearing when the file is uploaded (FileCount etc.)
      progress["SecondaryTotal"] = "0";
      progress["SecondaryValue"] = "0";
      progress["SecondaryPercent"] = "0";
   }
}
自定义进度条
<radu:radprogressarea runat="server" id="RadProgressArea1" skin="Vista"
    progressindicators="FilesCount,FilesCountBar,FilesCountPercent" />

 
4 控件使用说明
安装r.a.d control 安装包后,查看组件的详细使用帮助
5 待改进的方面
 

参考1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

rad 上传空间二次开发指导书