2010-04-28 76 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

相关问题