专注于技术经验交流

水至清则无鱼、宁静而致远!

技术、经验、学习共同打造网络新生活!
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

类似邮箱附件上传功能的自动增加列

Posted on 2006-09-21 15:38  小鱼儿  阅读(676)  评论(0编辑  收藏  举报
前台部分:
名称:


JS脚本事件: 后台cs代码 for(int Index = 0; Index文件名: '{0}'
文件大小: {1} bytes
文件类型: '{2}'
", //PostedFile.FileName, PostedFile.ContentLength, PostedFile.ContentType)); if(PostedFile.FileName=="") { Response.Write(""); return; } else { string RelativePath = Path.Combine("Received Files",Path.GetFileName(PostedFile.FileName)); string AbsolutePath = this.Page.MapPath(this.Page.ResolveUrl(RelativePath)); PostedFile.SaveAs(AbsolutePath); string[] aa=Request["FileName"].Split(",".ToCharArray()); data.BARGAIN_SERIALNUMBER = id; data.BARGAIN_ANNEX_NAME = aa[Index]; data.BARGAIN_ANNEX_PATH = PostedFile.FileName; DataLink.InsertBARGAIN_ANNEX(data); } } } 进度条页面 <%@ Page language="c#" Codebehind="Progress.aspx.cs" AutoEventWireup="false" Inherits="Web.Pages.ProgressBar" %> <%=percents %>
文件上传中……:



进度条cs代码; using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Mediachase.FileUploader; namespace Web.Pages { /// /// Summary description for ProgressBar. /// /// public class ProgressBar : System.Web.UI.Page { private int percents; protected string Percents { get { if (percents>0) return percents.ToString()+ "% of 完成";//Uploading Completed else return "Wait for Uploading Starts"; } } protected string PercentsAbs { get { return percents.ToString()+ "%"; } } // Fix: keyword new was added by Artem. protected new string ID { get { return Request["ID"]; } } protected System.Web.UI.WebControls.Label lblTransferred; protected System.Web.UI.WebControls.CheckBox cbClose; protected System.Web.UI.HtmlControls.HtmlGenericControl dWinClose; protected System.Web.UI.HtmlControls.HtmlGenericControl rMeta; protected System.Web.UI.HtmlControls.HtmlGenericControl body; private void Page_Load(object sender, System.EventArgs e) { if (ID!=null) { try { int Total; int Received; bool PostCompleted; FormInfo formInfo = McFormProgress.GetFormInfo(ID); McFormProgress.GetFormPostProgress(ID,out Received,out Total,out PostCompleted); lblTransferred.Text = (Received/1024).ToString(); if (Total > 0) { percents = (int)((float)Received / (float)Total * 100); lblTransferred.Text = "上传中 " + (Received/1024).ToString() +" Kb of " + (Total/1024).ToString() + " Kb." + "
当前文件:'" + formInfo.CurrentFileName + "'
预计时间:" + formInfo.EstimatedTime.ToString().Substring(0, 8) + "
剩余时间:" + formInfo.TimeRemaining.ToString().Substring(0, 8); } else { //Response.Write(""); //lblTransferred.Text = "文件过大!"; percents = 0; } if (PostCompleted) { if (Total != Received) { lblTransferred.Text = "上传失败!";//Uploading Failed } else { lblTransferred.Text = "上传文件成功!";//Uploading Completed Sucessfully if (cbClose.Checked) dWinClose.Visible = true; } } else { body.Attributes.Add("onload","setTimeout('refresh()', 2000)"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } } 需要引用的上传控件名称 Mediachase.FileUploader
New Document