服务器在Asp.net C#中等待文件保存完成(Server Wait file save complete in Asp.net C#)

我将图像文件保存到Form_Load文件夹中,并在客户端使用该image 。 有时不显示image 。 但在刷新页面image显示。 我希望服务器等到image保存完成。

System.Drawing.Image barcodeImage = b.Encode(BarcodeLib.TYPE.CODE128, lstTicket[0].Barcode.ToString(), 250, 100); barcodeImage.Save(Server.MapPath("~/temp/") + lstTicket[0].Barcode.ToString() + ".jpg");

和客户端

<div id="Barcode" style="text-align: center; margin-top: 10px;"> <img src="/temp/<%=item.Barcode + ".jpg"%>" style="width: 200px; height: 40px;" /> </div>

I save image file into folder in Form_Load and used that image in client side. sometimes does not show image . but after refresh page image show. I want server wait till image saved complete.

System.Drawing.Image barcodeImage = b.Encode(BarcodeLib.TYPE.CODE128, lstTicket[0].Barcode.ToString(), 250, 100); barcodeImage.Save(Server.MapPath("~/temp/") + lstTicket[0].Barcode.ToString() + ".jpg");

and Client Side

<div id="Barcode" style="text-align: center; margin-top: 10px;"> <img src="/temp/<%=item.Barcode + ".jpg"%>" style="width: 200px; height: 40px;" /> </div>

最满意答案

我有同样的问题,你的解决方案是:

您可以使用

$(window).on("load"),function(){}

代替

$(document).ready(function () {}

加载条形码图像后,警报框才会出现,您的问题将得到解决

I have the same problem and your solution is :

You can use

$(window).on("load"),function(){}

instead of

$(document).ready(function () {}

the alert box doesn't appear until after your barcode image are loaded and your problem will be solve

更多推荐

image,Barcode,barcodeImage,jpg,保存,电脑培训,计算机培训,IT培训"/> <meta name=&