如何让beforeSubmit属性只对一个submit有效
展开全部
您好,您这样:
<!DOCTYpE html pUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="js/jquery-1.3.2.js" ></script>
<%--<script src="js/jquery-1.4.1.js" type="text/javascript"></script>--%>
<script type="text/javascript" src="js/jquery.blockUI.js" ></script>
<script type="text/javascript" src="js/jquery.form.js" ></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.js" ></script>
<script type="text/javascript" src="js/upload.js" ></script>
<link href="css/ui.theme.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#ui{ color:#aaaaaa; }
.ui-progressbar-value { background-image: url(css/images/pbar-ani.gif); }
.percentText{LINE-HEIGHT: 20px;font-size:12px; font-weight:bold; color:#ffffff ; text-align:center; }
.ui-progressbar { height:2em; text-align: left; }
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
</style>
</head>
<body>
<form id="uploadForm" runat="server" enctype="multipart/form-data">
<div id="uploadfield" style="width:300px; height:30px">
<input id="File1" type="file" runat="server" />
<asp:Button ID="Button1" runat="server" Text="上传" onclick="Button1_Click" />
</div>
<div id="ui" style="display:none" >
<div id="output" > </div>
<div id="progressbar"class="ui-progressbar ui-widget ui-widget-content ui-corner-all" style="width:296px; height:20px;"></div>
<input id="btn_cancel" type="button" value="取消上传" />
</div>
</form>
</body>
</html>
后台页:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BigFileUploadHandle;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BigFileUploadHandle.UploadContext context = BigFileUploadHandle.UploadContextFactory.InitUploadContext(this, Request.MapPath("~/temp/")); // 指定临时目录
}
protected void Button1_Click(object sender, EventArgs e)
{
BigFileUploadHandle.UploadContext context = BigFileUploadHandle.UploadContextFactory.GetUploadContext();
string FileName = context.GetFileNameByControl(File1.UniqueID);
string filePath = Request.MapPath("~/myupload/");
if ((context != null) && (context.Status == BigFileUploadHandle.uploadStatus.Complete))
{
if (context.SaveFile(File1.UniqueID, filePath + FileName))
{
BigFileUploadHandle.UploadContextFactory.Release();//释放资源 删除临时文件
}
}
}
}
<!DOCTYpE html pUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="js/jquery-1.3.2.js" ></script>
<%--<script src="js/jquery-1.4.1.js" type="text/javascript"></script>--%>
<script type="text/javascript" src="js/jquery.blockUI.js" ></script>
<script type="text/javascript" src="js/jquery.form.js" ></script>
<script type="text/javascript" src="js/jquery-ui-1.7.2.custom.js" ></script>
<script type="text/javascript" src="js/upload.js" ></script>
<link href="css/ui.theme.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#ui{ color:#aaaaaa; }
.ui-progressbar-value { background-image: url(css/images/pbar-ani.gif); }
.percentText{LINE-HEIGHT: 20px;font-size:12px; font-weight:bold; color:#ffffff ; text-align:center; }
.ui-progressbar { height:2em; text-align: left; }
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
</style>
</head>
<body>
<form id="uploadForm" runat="server" enctype="multipart/form-data">
<div id="uploadfield" style="width:300px; height:30px">
<input id="File1" type="file" runat="server" />
<asp:Button ID="Button1" runat="server" Text="上传" onclick="Button1_Click" />
</div>
<div id="ui" style="display:none" >
<div id="output" > </div>
<div id="progressbar"class="ui-progressbar ui-widget ui-widget-content ui-corner-all" style="width:296px; height:20px;"></div>
<input id="btn_cancel" type="button" value="取消上传" />
</div>
</form>
</body>
</html>
后台页:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BigFileUploadHandle;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BigFileUploadHandle.UploadContext context = BigFileUploadHandle.UploadContextFactory.InitUploadContext(this, Request.MapPath("~/temp/")); // 指定临时目录
}
protected void Button1_Click(object sender, EventArgs e)
{
BigFileUploadHandle.UploadContext context = BigFileUploadHandle.UploadContextFactory.GetUploadContext();
string FileName = context.GetFileNameByControl(File1.UniqueID);
string filePath = Request.MapPath("~/myupload/");
if ((context != null) && (context.Status == BigFileUploadHandle.uploadStatus.Complete))
{
if (context.SaveFile(File1.UniqueID, filePath + FileName))
{
BigFileUploadHandle.UploadContextFactory.Release();//释放资源 删除临时文件
}
}
}
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询