2016-12-30 4 views
0

特定のpptをクリックするとリストにいくつかのpptファイルがあり、各スライドのイメージを生成してfolder.Nowに保存しています私はすべての画像をリストに表示したい。 ここに画像を表示する私のHTMLがあります。ここでmvcでイメージのsrcが異なるときにリストに間違ったイメージが表示される

<div class="sideBySide"> 
 
     <div id="dvLeft" class="left" style="overflow: scroll; height: 400px; float: left"> 
 
            
 
      
 
     </div> 
 
     <div class="right" > 
 
      <ul class="target connected" style="float: left; width: 300px"></ul> 
 
     </div> 
 
     
 
    </div>

私はPPTをクリックしています最初の時間は、それがLだときに私のスクリプトここ

$(".lnk").click(function (e) { 
 
       e.preventDefault(); 
 
       var vPath = $(this).attr("href"); 
 
       debugger; 
 
       //$("#viewPlaceHolder").load("/home/generateImageList?strPath=" + $(this).attr("href")); 
 
       //$(".left").html("/home/generateImageList?strPath=" + $(this).attr("href")); 
 
       //$("#iPPT").attr("src", $(this).attr("href")); 
 

 
       //--------------- 
 
       $.ajax({ 
 
        type: "POST", 
 
        data: { "strPath": vPath }, 
 
        url: '@Url.Action("generateImageList", "home")', 
 
        success: function (result) { 
 
         alert(result); 
 
         $('#dvLeft').empty(); 
 
         $('#dvLeft').html(result); 
 
         //$('.left').html("<ul class='source connected'><li>Audi</li></ul>"); 
 
         $(".source, .target").sortable({ 
 
          connectWith: ".connected" 
 
         }); 
 
        } 
 
       }); 
 
       //--------------- 
 
      }) 
 
     });
は、自分の行動

public ActionResult generateImageList(string strPath) 
    { 
     try 
     { 

      // load a PowerPoint document 
      PPTXDocument doc = new PPTXDocument(strPath); 

      //Delete files 
      System.IO.DirectoryInfo di = new DirectoryInfo(@"D:\Sajal\ResterEdgeApiTest\PPTSlider\Test\"); 

      foreach (FileInfo file in di.GetFiles()) 
      { 
       file.Delete(); 
      } 

      // convert all PowerPoint document pages/slides to PNG files 
      // page index will automatically append to the file name 
      doc.ConvertToImages(ImageType.PNG, @"D:\Sajal\ResterEdgeApiTest\PPTSlider\Test\", "0"); 

      DirectoryInfo dirInfo = new DirectoryInfo(@"D:\Sajal\ResterEdgeApiTest\PPTSlider\Test\"); 
      List<FileInfo> files = dirInfo.GetFiles().OrderBy((f) => Int32.Parse(Path.GetFileNameWithoutExtension(f.Name))).ToList(); 
      List<clsPPT> ppts = new List<clsPPT>(); 
      int i = 1; 

      /****************************/ 
      StringBuilder sb = new StringBuilder(); 
      sb.Append("<ul class='source connected' style='float: left'>"); 
      /****************************/ 

      foreach (var item in files) 
      { 
       clsPPT cp = new clsPPT(); 
       cp.strName = item.Name; 

       string strPath1 = @"http://localhost:63714/Test/" + item.Name; 
       //Uri myuri = new Uri(strPath1); 
       cp.strPath = strPath1;//myuri; 
       cp.rowNo = i; 
       ppts.Add(cp); 
       sb.Append("<li><p>" + i.ToString() + "</p><img id='" + i + "' src='" + strPath1 + "' height='200' width='300' alt='" + strPath + "' /></li>"); 
       i = i + 1; 
      } 
      sb.Append("</ul>"); 
      ViewBag.htmlDesig = sb.ToString(); 
      //return PartialView("~/Views/Home/_ppSlideList.cshtml", ppts); 
      //return PartialView("~/Views/Home/_ppSlideListNew.cshtml", ppts); 

      return Json(sb.ToString()); 
     } 
     catch (Exception ex) 
     { 
      throw ex; 
     } 
    } 

です私は2番目のpptをクリックするとリストの画像生成とhtml生成は成功しますが、それはintフォルダが存在しない以前の画像を表示しています。

答えて

0

にとあなたのAJAX呼び出しにcache: falseを追加します。

$.ajax({ 
    type: "POST", 
    cache: false, 
    ... 
}); 
+0

@prashant sonaleを動作していません – Banti

関連する問題