打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
uploadify控件在QQ、TT、firefox浏览器中不工作以及在updatecontrol中不工作的解决办法

一:在QQ、TT浏览器中,uploadify上传控件不能正常工作,显示出了上传进度条,但是进度不走。解决办法如下,在前台初始化uploadify控件时,‘uploader’属性需要加随机数,让uploadify.swf文件重新下载到IE临时文件夹。在js中我加入了时间戳:"uploader""../js/jquery.uploadify-v2.1.4/uploadify.swf?t=" + new Date().getTime()

 

二:解决在FireFox中不工作,需要做如下4步修改:

1、Global.asax文件中,实现Application_BeginRequest函数:

 

void Application_BeginRequest(object sender, EventArgs e) 
    {
        try
        {
            string session_param_name = "ASPSESSID";
            string session_cookie_name = "ASP.NET_SessionId"
            if (HttpContext.Current.Request.Form[session_param_name] != null)
            {
                updatecookie(session_cookie_name, HttpContext.Current.Request.Form[session_param_name]);
            }
            else if (HttpContext.Current.Request.QueryString[session_param_name] != null)
            {
                updatecookie(session_cookie_name, HttpContext.Current.Request.QueryString[session_param_name]);
            }
        }
        catch
        {
        }

        //此处是身份验证
        try
        {
            string auth_param_name = "AUTHID"
            string auth_cookie_name = FormsAuthentication.FormsCookieName;
            if (HttpContext.Current.Request.Form[auth_param_name] != null)
            {
                updatecookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
            }
            else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
            {
                updatecookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
            }
        }
        catch { }

 } 

    

 

2、前台js修改,注意红色代码:

 1 <script type="text/javascript">
 2         function pageLoad() {
 3             var auth = $("#<%=hfAuth.ClientID %>").val();
 4             var AspSessID = $("#<%=hfAspSessID.ClientID %>").val();
 5             $("#uploadify").uploadify({
 6                 "uploader": "../js/jquery.uploadify-v2.1.4/uploadify.swf?t=" + new Date().getTime(),
 7                 "script": "../JQueryUploadHandler.ashx?type=logo",
 8                 "cancelImg": "../js/jquery.uploadify-v2.1.4/cancel.png",
 9                 "folder": "../images/UploadFile",
10                 "queueID": "fileQueueImg",
11                 "auto": true,
12                 "multi": false,
13                 "height": 22,
14                 "buttonImg": "../images/file_select.png",
15                 "fileDesc": "图片文件",
16                 "fileExt": "*.gif;*.jpg;*.jpeg;*.png",
17                 "removeCompleted": true,
18                 "simUploadLimit": "1",
19                 scriptData: { ASPSESSID: AspSessID, AUTHID: auth },
20                 onComplete: function(event, queueID, fileObj, response, data) {
21                 alert("文件:" + fileObj.name + " 上传成功");
22                 },
23                 onError: function(event, queueID, fileObj) {
24                     alert("文件:" + fileObj.name + " 上传失败");
25                 }
26             });
27            
28         }

29 </script>  


 

3、前台页面加入两个隐藏控件:

1 <asp:HiddenField ID="hfAuth" runat="server" />

2 <asp:HiddenField ID="hfAspSessID" runat="server" /> 


 

4、后台pageload函数给两个隐藏控件赋值 :

1 if (!IsPostBack)
2         {
3             this.hfAuth.Value = Request.Cookies[FormsAuthentication.FormsCookieName] == null ?
4                 string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value;
5             this.hfAspSessID.Value = Session.SessionID;

 

 三:解决uploadify控件在updatepanel中不工作,需要每次updatepanel更新时,重新初始化uploadify控件,因此将初始化代码写到function pageLoad()的js函数中,并且后台pageload中加入如下代码,该行代码不能放入if (!IsPostBack)条件判定内部。

 

protected void Page_Load(object sender, EventArgs e)
{
        this.Page.RegisterClientScriptBlock("uploadStyle""<script>pageLoad()</script>");

 

 

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
C# MVC 中自定义权限特性[Authorize]中对于Ajax访问的处理
多附件上传控件plupload的使用心得
Reporting Services Single Sign On (SSO) Authe...
Jenkins部署项目到远端的TOMCAT下并自动化测试
网站全局缓存机制(类),可自动定时清理 --- 需触发 - .NET 3.x - 小组 -...
Asp.Net WebApi一个简单的Token验证
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服