標籤:c# asp.net 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 上傳空間二次開發指導書