Displaying an image using C # in a web application
I have a web application in which I have built a C # class that generates a report. This report takes about 40 seconds to generate as it searches hundreds of folders for specific files. So I was hoping there would be a way to display the Loading .. icon as this report was generated. I have a gif stored in My Pictures folder which would be perfect. The research I did at this point mostly talks about images and image controls that an image can contain, but I was hoping there was only a way to display the image above the post when it was created.
A web application from ADF Geocortex website and again I created a C # class that generates this report. Below is some code that might help.
/// <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))
{
a source to share
with this html ...
<div id="rpt">
<img src="Images/Load.Gif" />
</div>
then jQuery ajax post on document.ready ..
<script type="text/javascript">
$(function() {
$.post("/path/to/report", function(reportHtml) {
$("#rpt").html(reportHtml);
});
});
</script>
When the ajax call returns, you replace the html div with a report. This will delete the image.
a source to share
Crystals report, SSRS report, custom report? It matters, but if you can determine when the report is finished loading. I would consider using client side javascript to display an image and then remove that image when the report has finished loading. Actually it's hard to give you more unless you give us some code examples or clarify in your question.
a source to share
Sounds like a job for JQuery ... here's the article I'm thinking of talks about what you are trying to achieve.
It will be down the line
- Loading pages. - insert spinner.gif in the middle of the div that will contain the report
- Use JQuery to get the url of the report so that it populates the div with the query results.
- When it loads the report, it should appear in the specified div.
a source to share