易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net支持大文件上传 NeatUpload

1.在工具箱中添加Brettle.Web.NeatUpload.dll,可以看到工具箱中出现InputFile等控件。
2.复制文件夹NeatUpload到根目录.
3.拖放使用上传控件InputFile和进度条ProgressBar,添加上传文件的按钮.aspx页面代码如下:
<body>
<form id="form1" runat="server">
<div>
<upload:InputFile id="AttachFile" runat="server"></upload:InputFile>
<asp:Button ID="Upload" runat="server" Text="Upload" 
OnClientClick="ToggleVisibility('ProgressBar','on')"
OnClick="Upload_Click"/>
<div id="ProgressBar"  style="display:none;">
<upload:progressbar id="pbProgressBar" runat="server" Inline="true"
Width="500px" Height="100"> </upload:progressbar>
</div>
</div>
</form>
</body>
4.添加脚本代码ToggleVisiblity函数到页面上如下:
<script type="text/javascript" language="javascript">
function ToggleVisibility(id, type)
{
el = document.getElementById(id);
if(el.style)
{
if(type == 'on')
{
el.style.display = 'block';
}
else
{
el.style.display = 'none';
}
}
else
{
if(type == 'on')
{
el.display = 'block';
}
else
{
el.display = 'none';
}
}
}
</script>
5.给上传文件的按钮添加事件Upload_Click
protected void Upload_Click(object sender, EventArgs e)
{
string FileName = this.AttachFile.FileName;//获取上传文件的全路径
string ExtenName = System.IO.Path.GetExtension(FileName);//获取扩展名
string SaveFileName =
System.IO.Path.Combine(Request.PhysicalApplicationPath,
DateTime.Now.ToString("yyyyMMddhhmm") + ExtenName);//合并两个路径为上传到服务器上的全路径
if (this.AttachFile.ContentLength > 0)
{
try
{
this.AttachFile.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
}
catch (Exception ex)
{
throw ex;
}
}
}
6.在配置文件web.config中添加http模块声明:
<ht


相关文档:

探讨ASP.NET MVC框架内置AJAX支持编程技术


传统型ASP.NET Web Forms是基于同时包含了表现层和后台代码的Web页面,所以,紧随其后出现的ASP.NET AJAX,特别是这个框架的服务器端控件并没有像它们本应该的那样光芒四射。于是,很多跟随AJAX时髦的ASP.NET开发者只是向ASP.NET页面中随意地放置一些UpdatePanel控件以便使其程序实现基本的AJAX支持。实际 ......

ASP.NET文件上传下载

下载文件:string musicUrl = "music/" + Request.QueryString["murl"].ToString();
string fileName = Request.QueryString["murl"].ToString();
string filePath = Server.MapPath(musicUrl);//路径
FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.Cl ......

21个Asp.Net经常会用到的函数集


1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
int 年=currentTime.Year;
1.3 取当前月
int 月=currentTime.Month;
1.4 取当前日
int 日=currentTime.Day;
1.5 取当前时
int 时=currentTime.Hour ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号