错误的JavaScript函数和jqeury异步文件上传错误 [英] Error JavaScript function and jqeury on async file upload error

查看:79
本文介绍了错误的JavaScript函数和jqeury异步文件上传错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用asp异步文件上传来上传图像文件.

I am tying to upload a image file using asp async file upload.

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        if (AsyncFileUpload1.HasFile)
        {
            string filext = Path.GetExtension(AsyncFileUpload1.FileName);
            if (filext == ".png")
            {

                //string path = Server.MapPath("temp/") + Path.GetFileName(e.FileName);
                string sessionId = this.Session.SessionID;
                string path = Server.MapPath("temp/") + sessionId + filext;
                AsyncFileUpload1.SaveAs(path);
                Response.Write("-" + path);
                string imgSrc = "temp/" + sessionId + filext;
                Session["projImage"] = path;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "showImage", "showImage('" + imgSrc + "');", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "errorMsgFunction", "errorMsgFunction();", true);
                return;

            }
        }

    }











ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "showImage", "showImage('" + imgSrc + "');", true);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "errorMsgFunction", "errorMsgFunction();", true);
            return;

        }










在这些图像中,一个带有图像的效果很好,我可以正确预览,但是第二个javascript函数在chrome中不起作用













out of these the one with image works fine and i can preview correctly but the second javascript funcion doesnot work in chrome




function showImage(imagePath)
       {

           $('#imgproj', window.parent.document).attr("src", imagePath);

       }













function errorMsgFunction(sender, args)
        {
            $('#diverror', window.parent.document).show();
            $('#diverror', window.parent.document).fadeOut(2000);

//            $('.errorproj', window.parent.document).fadeIn(4000, function()
//            {

//                $('.errorproj', window.parent.document).fadeOut(2000, function()
//                {
//                    $('.errorproj', window.parent.document).remove();
//                });
//            });

//            $('#diverror', window.parent.document).fadeIn(500, function()  {
//                $('#diverror', window.parent.document).fadeOut('slow');

//            });

        }

推荐答案

(' #imgproj ',window.parent.document).attr(" ,imagePath); }
('#imgproj', window.parent.document).attr("src", imagePath); }













function errorMsgFunction(sender, args)
        {


(' #diverror',window.parent. document).show();
('#diverror', window.parent.document).show();


(' #diverror',window.parent.document).fadeOut( 2000 ); //
('#diverror', window.parent.document).fadeOut(2000); //


这篇关于错误的JavaScript函数和jqeury异步文件上传错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆