2
我在使用ScriptManager的RegisterClientScriptBlock时无法正常工作。ASP.NET AsyncFileUpload RegisterClientScriptBlock不工作
我有一个AsyncFileUpload,我想上传后动态预览上传的图片。
的UploadedComplete在Page_Init有线和这里的在服务器端UloadedComplete块码
void fileUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string csb = string.Empty; string tempfolder = "picserver/posts/temp/" + Session["Username"] + "_" + DateTime.Today.ToString("yyyy_MM_d") + ".jpg"; string newfile = Server.MapPath(tempfolder); fileUpload.SaveAs(newfile); Byte[] f = File.ReadAllBytes(newfile); Imaging i = new Imaging(); i.ResizeImageFile(newfile, newfile, 64); csb = "$(\"" + postImagePreview.ClientID + "\").innerHTML = '<img src=\"" + tempfolder + "\" alt=\"\" />'"; System.Diagnostics.Debug.WriteLine("CSB: " + csb); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "preview", csb, true); }
和这里的HTML
<asp:Label ID="postImagePreview" runat="server" /> Upload a preview of your advertisement.
<asp:AsyncFileUpload ID="fileUpload" runat="server" UploaderStyle="Traditional" UploadingBackColor="#CCFFFF" ThrobberID="myThrobber" /> <asp:Label runat="server" ID="myThrobber" style="display:none;" ></asp:Label>
这里是我的脚本块
csb = "$(\"" + postImagePreview.ClientID + "\").innerHTML = '<img src=\"" + tempfolder + "\" alt=\"\" />'"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "preview", csb, true);
,它不工作..即使我把“警惕('你好');”在脚本参数中。仍然不起作用。
你们有什么想法?
控制上传文件“mscorlib.dll中发生类型'System.Threading.ThreadAbortException'的第一次机会异常时得到此输出 发生异常类型'System.Threading.ThreadAbortException'发生在mscorlib.dll中,但未在用户代码“ – jaysonragasa 2010-09-04 01:30:43
OMG中处理”。 args.get_path();返回“C:\ fakepath \ uploadedfile.ext” - FAKEPATH!?! – jaysonragasa 2010-09-04 01:52:49