2010-04-28 83 views
2

我有一個Web應用程序,我在其中構建了一個C#類生成報告。此報告需要近40秒才能生成,因爲它會搜索數百個文件夾中的某些文件。所以我希望在報告生成時有一種方法可以顯示「Loading ..」圖標。我有一個存儲在我的圖片文件夾中的GIF,這將是完美的。我在這一點上所做的研究主要是討論可以保持圖像的picturebox和圖像控件,但我希望只有在報表創建時在報表上方顯示圖像的方式。在Web應用程序中使用C#顯示圖像

Web應用程序來自Web ADF Geocortex網站,我又創建了一個生成此報告的C#類。以下是一些可能有所幫助的代碼。

/// <summary> 
    /// Generates HTML for the current report using the data in 
    /// the given table. 
    /// </summary> 
    /// <param name="reportLayers">The layers to include in the report.</param> 
    /// <returns> 
    public override string GenerateReportHtml(List<ReportLayer> reportLayers) 
    { 
     StringBuilder htmlString = new StringBuilder(); 
     StringWriter stringWriter = new StringWriter(htmlString); 
     HtmlTextWriter writer = new HtmlTextWriter(stringWriter); 



     string holdAPI = ""; 

     List<string> exclusions = GetExcludedFields(); 

     foreach (ReportLayer layer in reportLayers) 
     { 
      string[] strFiles = null; 
      Boolean val = false; 

      if (layer.Layer.Name == "Bottom Hole Location (OP)") 
      writer.RenderBeginTag(HtmlTextWriterTag.P); // <p> 
      writer.RenderBeginTag(HtmlTextWriterTag.Strong); // <strong> 
      writer.Write(layer.Layer.Name); 

      writer.RenderEndTag(); // end </strong> 
      writer.RenderEndTag(); // end </p> 

      writer.WriteBreak(); // <br /> 
      foreach (ReportFeature feature in layer.ReportFeatures) 
      { 

      // each feature will be in a table 
       writer.RenderBeginTag(HtmlTextWriterTag.Table); // <table> 

       foreach (ReportField field in feature.ReportFields) 
       { 
        string fieldName = field.Alias; 
        if (!exclusions.Contains(fieldName)) 
        { 
+0

我們需要更多的細節。你的問題含糊不清。 – 2010-04-28 21:14:03

+0

感謝給我負面的觀點。我是新來的...我會發布更多信息 – Josh 2010-04-28 21:15:42

+0

我有一個名爲Load.gif的圖像,它位於我的Web應用程序中的圖像文件夾中。我有一個C#類創建一個報告,這個報告需要40秒生成,所以我想顯示一個圖像,說明它正在加載.. – Josh 2010-04-28 21:18:21

回答

2

與這個網站...

<div id="rpt"> 
    <img src="Images/Load.Gif" /> 
</div> 

然後一個jQuery AJAX post上的document.ready ..

<script type="text/javascript"> 
    $(function() { 
     $.post("/path/to/report", function(reportHtml) { 
      $("#rpt").html(reportHtml); 
     }); 
    }); 
</script> 

當Ajax調用返回更換了報告的DIV HTML。這將刪除圖像。

1

水晶報告,SSRS報告,自定義報告?這有所作爲,但是如果您可以確定報告何時完成加載。我會考慮使用客戶端JavaScript來顯示圖像,然後在報告加載完成後刪除該圖像。真的很難給你更多,除非你給我們一些代碼示例或詳細說明你的問題。

1

聽起來像是JQuery的工作...這裏是an article,我想談談你想要達到的目標。

這將會是沿

  1. 頁面加載線。 - 將spinner.gif插入包含報告的div的中間
  2. 使用JQuery獲取報告url將其設置爲填充請求結果的div。
  3. 加載報告時,它應該出現在div中。
+0

@danswain:我會將其修改爲「JavaScript框架」,而不是特定的jQuery。 – R0MANARMY 2010-04-29 14:59:45

相關問題