2013-03-27 70 views
1

我使用MessagingToolkit.QRCode.dll创建了一个QR码图像。我已将图像保存在磁盘中。如何从视图中分别显示图像弹出?
这是我的控制器代码:如何在视图中显示类似弹出的图像

[HttpPost] 
public ActionResult GenerateQR(string Command, FormCollection collection) 
    { 
    // qr code logic // 
     QRCodeEncoder encoder = new QRCodeEncoder(); 
     Bitmap img = encoder.Encode(qrcode); 
     img.Save(@"D:\\Capture.png", ImageFormat.Jpeg); 
    // Checking the image present in the filepath and displaying the image. 
     string filePath = @"D:\\Capture.png"; 
     if (!System.IO.File.Exists(filePath)) 
      return Content("<script language='javascript' type='text/javascript'>alert('The Image is not available.');</script>"); 
     else 
      return new FilePathResult(filePath, "image/png"); 
    } 

在这里,图像被完全显示在视图中。如何在视图中将图像显示为单独的弹出窗口。

+0

使用jquery popup和ajax调用 – Sharun 2013-03-27 10:39:56

回答

0

而不是像一个弹出窗口,我直接从使用下面的代码获得图像。

QRCodeEncoder encoder = new QRCodeEncoder(); 
Bitmap img = encoder.Encode(qrcode); 
string path = Server.MapPath(@"/Images/QRCode.jpg");   
img.Save(path, ImageFormat.Jpeg);   
return base.File(path,"image/jpeg","QRCode.jpg"); 
相关问题