前台JS获取ASHXvar intervalID = 0;
intervalID = window.setInterval(function () {
$.ajax({
type: "POST",
datatype: "text",
url: "../Ajax/HandlerGetUploadProgress.ashx",
async: false,
cache: false,
data: { },
beforeSend: function () {
},
success: function (result) {
if (result != "null" && result == 100) {
clearInterval(intervalID);
$("#<%=lblShowProgress.ClientID %>").html("").hide();
}
else if (result != "null") {
$("#<%=lblShowProgress.ClientID %>").html(result + "%").show();
}
else {
$("#<%=lblShowProgress.ClientID %>").html("").show();
}
},
error: function (result, status) {
}
});
}, 500);ashx文件中if (context.Session != null && context.Session["ShopCurrentPercentage"] != null && context.Session["ShopTotalPercentage"] != null)
{
int currentpercentage = Convert.ToInt32(context.Session["ShopCurrentPercentage"]);
int totalpercentage = Convert.ToInt32(context.Session["ShopTotalPercentage"]);
context.Response.ContentType = "text/plain";
context.Response.Write(Math.Ceiling((double)currentpercentage * 100 / totalpercentage));
}
else
{
context.Response.ContentType = "text/plain";
context.Response.Write(DateTime.Now.ToString("yyyyMMddhhmmss"));
}
intervalID = window.setInterval(function () {
$.ajax({
type: "POST",
datatype: "text",
url: "../Ajax/HandlerGetUploadProgress.ashx",
async: false,
cache: false,
data: { },
beforeSend: function () {
},
success: function (result) {
if (result != "null" && result == 100) {
clearInterval(intervalID);
$("#<%=lblShowProgress.ClientID %>").html("").hide();
}
else if (result != "null") {
$("#<%=lblShowProgress.ClientID %>").html(result + "%").show();
}
else {
$("#<%=lblShowProgress.ClientID %>").html("").show();
}
},
error: function (result, status) {
}
});
}, 500);ashx文件中if (context.Session != null && context.Session["ShopCurrentPercentage"] != null && context.Session["ShopTotalPercentage"] != null)
{
int currentpercentage = Convert.ToInt32(context.Session["ShopCurrentPercentage"]);
int totalpercentage = Convert.ToInt32(context.Session["ShopTotalPercentage"]);
context.Response.ContentType = "text/plain";
context.Response.Write(Math.Ceiling((double)currentpercentage * 100 / totalpercentage));
}
else
{
context.Response.ContentType = "text/plain";
context.Response.Write(DateTime.Now.ToString("yyyyMMddhhmmss"));
}
解决方案 »
- 电子商城数据加载问题
- 紧急求助,图片上传。。。。
- c# 如何判断FTP IP 、用户名和密码来判断是否链接FTP成功;
- 在mssql中什么是数据库计划,怎样设置数据库计划
- Session整合得问题,在一个子目录登录,无法在另一个子目录获取值
- 求一语句,把sql2005中的数据表aa导出成excel(aa.xls),谢了,在线等
- DataTable中的数据是7行,如何让Datagrid绑定后变10行,其中7行是数据,另外3行为空。
- 导出报表时出错,提示【无法找到清单资源中的报告。请创建项目并再次尝试】?
- #define 预处理器指令
- 求助! 怎样从AD中读取到当前的登陆用户名?
- 急急急 求大神 如何实现数据横向排列这种效果?
- 视频播放代码问题
using System.Web;
using System.Web.SessionState;public class VerificationHandler : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest (HttpContext context) {
string Verification = context.Request["Verification"].ToLower();
if (Verification != context.Session["validate_code"].ToString().ToLower()) //判断用户填写的验证码和生成的验证码是否一致,当不一致时触发的事件
{
context.Response.Write("false");
}
else
{
context.Response.Write("true");
}
}
public bool IsReusable {
get {
return false;
}
}}
楼主请给分