I am using the ASP.Net Charting Controls and ASP.Net MVC.
I am trying to have a chart displayed on a page, the user can change various data associated with this chart and then press a button which will perform a POST operation and then return a newly rendered chart. This is refreshed via jQuery which loads a partial view containing the chart.
The problem I am having is that in IE 7 I get the image could not be found icon. Bizarrely it works fine in Firefox!
The process of updating chart:
- Send new parameters in a POST
- Application changed parameters on the chart object
- Controller sends Chart Object to Partial View which renders it like a control
- jQuery then loads in this partial view. In IE 7 i get the image not found icon.
Here is the code used in the Partial View to render the Chart Object:
if (Model.Chart != null)
{
Model.Chart.Page = this.Page;
System.Web.UI.DataVisualization.Charting.Chart Chart1 = Model.Chart;
using (HtmlTextWriter writer = new HtmlTextWriter(this.Response.Output))
{
try
{
Chart1.ImageType = System.Web.UI.DataVisualization.Charting.ChartImageType.Jpeg;
Chart1.RenderControl(writer);
}
catch (Exception ex)
{
writer.WriteEncodedText(ex.Message);
}
}
}
Cheers!
The jQuery which loads these charts is as follows:
function PostWidgetDataOverride(ChartID) {
$.ajax({
url: "/Home/GetChart",
type: "POST",
dataType: "HTML",
data: { ChartID: ChartID, SeriesID: $('.SeriesID').val(), ParameterDefaults: $('.parameterDefault').serialize(), Time: getTimeStamp() },
success: UpdateChart
});
}
function UpdateChart(ChartContent) {
$("#widgetConfig").dialog("close");
var existingChart = CheckIfWidgetIsOnPage($(ChartContent).attr("id"))
if (existingChart !== undefined) {
existingChart.fadeOut("slow", function() { existingChart.replaceWith(ChartContent); }).fadeIn("slow");
}
else {
$(ChartContent).appendTo($("#dashboardArea")).fadeIn("slow");
}
}