ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Chart Director causing a blank web page
Posted by TL on Apr-10-2011 17:55
Hi, I'm facing the following problem:

I have a fine working web page where I want to add a multi bar chart. Now, when I add the code (to aspx.cs) that creates the chart, the browser displays just a blank web page: I mean, not just the chart is not displayed, but all the other components of the page (labels, textboxes, grid view etc...) as well!

I don't get any errors.

I tried to copy - paste a sample code from the ChartDirector documentation instead of my code (that part that creates the chart), no help.

When I remove that part of code, the page is displayed fine.

Any help will be greeted.
TL.

  Re: Chart Director causing a blank web page
Posted by Peter Kwan on Apr-12-2011 00:15
Hi TL,

Please kindly try the original "simplebar.aspx" sample code that comes with ChartDirector without any modification. This is use to check if ChartDirector is installed correct in your web site. If the original unmodified "simplebar.aspx" works, then ChartDirector should be installed correctly.

In this case, please inform me how you are copying the code to your own "aspx.cs". May be you can create a simple "Hello World" web page, and copy the charting code to it, and try to see if it works. If it does not work, please kindly attach both the "aspx" and "aspx.cs". I will try to double check to see if there is any issue.

In brief, to include the charting code in "aspx.cs", first drag and drop a WebChartViewer control to the WebForm, then include the charting code in the Page_Load event in your "aspx.cs", like:

// The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};

// The labels for the bar chart
string[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};

// Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(250, 250);

// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200);

// Add a bar chart layer using the given data
c.addBarLayer(data);

// Set the x axis labels using the given labels
c.xAxis().setLabels(labels);

// Output the chart
WebChartViewer1.Image = c.makeWebImage(Chart.PNG);

// Include tool tip for the chart
WebChartViewer1.ImageMap = c.getHTMLImageMap("", "",
    "title='{xLabel}: US${value}K'");

You would also need to add the line "using ChartDirector;" at the top of the "aspx.cs" to import the ChartDirector namespace.

Hope this can help.

Regards
Peter Kwan

  Re: Chart Director causing a blank web page
Posted by TL on Apr-12-2011 22:49
Thank you for your response,
I tried few things, and I steel don't understand where is the problem:
I have another web page where I already have three charts (that displayed fine). I tried to add a fourth chart using "simplebar.aspx" sample code, and all was OK.
Yet, when I add the same code in the page I wanted originally, the page is not displayed.
Another thing I tried, is to add a chart in a web page that doesn't contain a chart yet, and this worked fine, to.
All the web pages I'm talking about are in the same project.

Any ideas?

  Re: Chart Director causing a blank web page
Posted by Peter Kwan on Apr-13-2011 01:44
Hi TL,

Because the problem is specific to one particular aspx.cs you are using, may be you can sent me your aspx.cs and aspx to diagnose the problem. If you cannot post the code in the forum, you may email me at pkwan@advsofteng.net

If the entire web page does not display, does the browser wait for the server for the output indefinitely without terminating the connection, or does the browser terminate the connection? Does the server hangs with CPU going to 100%? In the server log file, does it see the browser request and respond accordingly, or is there any error message in the log file? Sometimes a system may be configured so that the error message is not sent to the browser (to avoid the end user from seeing the error message). If this is the case, you may configure your server to send the error message to the browser so you can see the actual error.

Since you have a web page that works, and a web page that does not work, a common strategy to trouble-shoot the porblem is delete or comment out the code in the web page that does not work. As you comment out more and more code, then at some stage the web page should start working. By analysing the code that are commented out to make it work, it may help to identify the cause of the issue.

Regards
Peter Kwan

  Re: Chart Director causing a blank web page
Posted by TL on Apr-13-2011 22:00
Thank you Peter,
I finally found the source of the problem!
when the browser displayed an empty page, I right-clicked on it, and chose "view source". There I saw a very funny thing: most of the code was commented (green)! Therefor it wasn't executed...
What caused it was a comment like "<!--blabla->" in aspx. According to HTML syntax, it supposed to be  "<!--blabla-->", but it turns out that the Visual Studio environment is lenient to that form of comment, so in the editor it doesn't cause all the following code be commented.
But, it appears that the browser is not so tolerant, so if it sees "<!--" and no "-->" after it somewhere, it comments all to the end.

What I still don't understand is, how come the code that contains ChartDirector instance, caused the browser not to execute the commented code?
Remember that when I removed that code from aspx.cs , the page was displayed just fine, while still having the problematic "<!--blabla-> comment in the aspx.
I checked that. I clicked "view source" on the page that was displayed fine (without the chart director), and it was almost all commented, to! and it was displayed!

Now I fixed the comments to the right syntax, and finally the page is displayed fine (yes, with the chart), But I'm still curious...
Any ideas what's going on?

  Re: Chart Director causing a blank web page
Posted by Peter Kwan on Apr-14-2011 01:41
Hi TL,

If you would like me to look at the reason, you may inform me of the HTML source to the two cases to me. You may simply save the two web pages (using "File/Save As" from the browser) and attach them, or email them to me.

Hope this can help.

Regards
Peter Kwan

  Re: Chart Director causing a blank web page
Posted by Peter Kwan on Apr-15-2011 01:45
Hi TL,

I have received your information. The reason the web page is not displayed is because all your code has been commented out by "<!--" and "-->". If you look carefully in the page that does not display, you can find a "<!--" near the beginning of your page, and a "-->" near the end of your page, which means the complete page has been commented out. (The "-->" is automatically generated by ASP.NET if there is any control in your page that can post back via Javascript. It is not generated by ChartDirector.)

In the web page that is visible, you only have a "<!--". There is no "-->" at all. I suspect the browser will not consider this as a comment. So the page is not commented out.

Hope this can help.

Regards
Peter Kwan