Microsoft Chart control for .NET Framework about state management and serialization problem, it works OK with one XML file but fails with another XML file

I use Microsoft Chart control for .NET Framework , you can see details at

The Chart1 is load data from a xml and save to ViewStateData, so even if after I click Reload button, the chart1 still display OK!

I'm very strange that the chart1 works well after click Reload button if it's loaded from Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/1.xml"));
but chart1 don't display fter click Reload button if it's loaded from Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/Default.xml"));

What happened?

You can download the code at to test!

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Admin_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <asp:Chart ID="Chart1" runat="server" EnableViewState="True">
            <asp:ChartArea Name="ChartArea1">
    <br />
    <br />
    <br />
    <asp:Button ID="btnLoad" runat="server"  Text="ReLoad" />
    <br />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.UI.DataVisualization.Charting;
using DIYChart.BLL;
using DIYChart.Model;

public partial class Admin_Default : System.Web.UI.Page

    private void Form_Init(object sender, System.EventArgs e)
       Chart1.EnableViewState =true;

    protected void Page_Load(object sender, EventArgs e)
        Chart1.EnableViewState = true;
        if (IsPostBack ==false)
            //Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/Default.xml"));  //The chart don't display after click Reload button
            Chart1.Serializer.Load(HttpContext.Current.Server.MapPath("~/Template/1.xml")); //The chart Display OK after click ReLoad

            StringWriter sw = new StringWriter();
            Chart1.Serializer.Content = SerializationContents.All;

            Chart1.ViewStateData = sw.ToString();

            if (Chart1.ViewStateData != null)
                StringReader sr = new StringReader(Chart1.ViewStateData);
                Chart1.Serializer.Content = SerializationContents.All;



<Chart EnableViewState="True">
    <Series Name="Input" ChartArea="ChartArea1">
        <DataPoint YValues="10" />
        <DataPoint YValues="11.875098755525" />
        <DataPoint XValue="1" YValues="10.5118472299128" />
        <DataPoint XValue="2" YValues="11.1791341785244" />
        <DataPoint XValue="3" YValues="0" />
        <DataPoint XValue="4" YValues="0" />
    <ChartArea Name="ChartArea1">

<Chart BackColor="243, 223, 193" Width="412" Height="296" BackGradientStyle="TopBottom" BorderColor="181, 64, 1" BorderWidth="2">
    <Series Name="Series1" Legend="Default" XValueType="DateTime" ChartArea="ChartArea1" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder, PointWidth=0.8">
        <DataPoint XValue="36890" YValues="32" />
        <DataPoint XValue="36891" YValues="56" />
        <DataPoint XValue="36892" YValues="35" />
        <DataPoint XValue="36893" YValues="12" />
        <DataPoint XValue="36894" YValues="35" />
        <DataPoint XValue="36895" YValues="6" />
        <DataPoint XValue="36896" YValues="23" />
    <Series Name="Series2" Legend="Default" XValueType="DateTime" ChartArea="ChartArea1" BorderColor="180, 26, 59, 105" CustomProperties="DrawingStyle=Cylinder, PointWidth=0.8">
        <DataPoint XValue="36890" YValues="67" />
        <DataPoint XValue="36891" YValues="24" />
        <DataPoint XValue="36892" YValues="12" />
        <DataPoint XValue="36893" YValues="8" />
        <DataPoint XValue="36894" YValues="46" />
        <DataPoint XValue="36895" YValues="14" />
        <DataPoint XValue="36896" YValues="76" />
    <ChartArea Name="ChartArea1" BackColor="OldLace" BackGradientStyle="TopBottom" BackSecondaryColor="White" ShadowColor="Transparent" BorderColor="64, 64, 64, 64">
      <AxisY LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8">
        <MajorGrid LineColor="64, 64, 64, 64" />
        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" Format="C0" />
      <AxisX LineColor="64, 64, 64, 64" LabelAutoFitMaxFontSize="8">
        <MajorGrid LineColor="64, 64, 64, 64" />
        <LabelStyle Font="Trebuchet MS, 8.25pt, style=Bold" IsEndLabelVisible="False" Format="MM-dd" />
      <Area3DStyle Rotation="10" IsRightAngleAxes="False" Perspective="10" Inclination="15" WallWidth="0" />
    <Legend Name="Default" Enabled="False" IsTextAutoFit="False" BackColor="Transparent" Font="Trebuchet MS, 8.25pt, style=Bold">
    <Title ShadowColor="32, 0, 0, 0" Text="Column Chart" Font="Trebuchet MS, 14.25pt, style=Bold" ForeColor="26, 59, 105" ShadowOffset="3" Name="Title1">
  <BorderSkin SkinStyle="Emboss" />


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
1/17/2009 5:59:25 AM 3977 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 40
Get it on Google Play
Get it on Apple App Store

Hi mycwcgr,

I think you should check your xml file from the following aspects:

(1)Check whether the path is right.

(2)Check whether the format is right.

Hua Jun Li
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
1/21/2009 3:00:59 AM

Similar Artilces:

transform one xml file into xml file with another format?
 I want to transform one xml file into xml file with another format, can I use xslt to realize it? Please give me one good sample.Thanks. Hi, Yes you can use xsl to do this. See this article for more information. In the artile the xsl transforms xml into html. similarly you can transform xml to another format xml using xsl  Please mark post as answer if it helped youMy Blog...

XML Transform to 1 XML file to another XML File
Hello All  I am a novice programmer. I want to transform 1 xml file to another xml file. I am looking for a example code where user will select source xml file and create another xml file in different file with different fields with some default validation of parsing date and default values.  Can anyone help me or let me know any available source code in C#/ASP.Net?  Ms Disha I am assuming you know xslt, if not, you would have to go look at that.  But if you do, then this document will help you out

Problems writing to an XML file
I'm brand new to using XML (in fact this is my first project), so bear with me, I may need a little hand-holding. I'm trying to create a page which simply adds data to an existing xml file. Ultimately it will add the data from a form, but to keep things simple, I've been simply using pre-defined values. Originally I was able to get the script to write the xml exactly as I needed, however it would simply overwrite the existing file every time it was accessed. This is unacceptable, as it will be used to add data to one file, sort of like a mini database. So after much pain and gnashi...

serialize a XML file to a VB.NET file (class) using xsd
Hello   I would like to serialize  a XML file to a VB.NET  file (class).   How can I use XSD.exe  to generate my xml file  C:\leye_g\Travaux\Fichiers de données\test.xml  to a VB.NET File ?   Best regardsf Hi XML Schema Definition Tool (Xsd.exe)  can generate runtime classes from  XSD files . XmlElementAttribute Is Missing for the Generated Class Members While Using Xsd.exe describes how to generate class from xml and reports a problem. And you could find more info here: Code Generation in the .NET Framework Using XML Sch...

Create an XML file from another XML file
I am using VS 2005 with C#.  I would like to create/generate an xml file from another XML with a differnt structure.  Basically, I want to create the actual xml file for my users whenever they raise my web service method. This is the actual structure of my xml i would like to create the following <Education>  <mydata>    <year>1988 - 1995</year>    <reward>High School Diploma</reward>    <school>Miami Secondary</school>  </mydata>  ...</Education> The original ...

how can i merge multiple xml files into one single xml file
hello i need to merge multiple xml files into a single xml file without losing the hierarchy of the xml document..... pls help regards shabari IS it really include or merge? Including is easy, merge - not. The complexity depends on your merge logic. Show us some samples.Oleg [XML MVP, MCPD]XmlLab.Net |

Replace a node from 1 xml file with a node from another xml file
Hi,  suppose i have these 2 xml files: File 1: <resultset morerecords="0" paging-cookie="1">accountid last="{D14D44AD-36D0-DC11-AA32-0003FF33509E}" first="{D14D44AD-36D0-DC11-AA32-0003FF33509E}" /></cookie>"> <result> ... <donotpostalmail name="Allow">0</donotpostalmail> <name>Adventure Works</name> <primarycontactid name="Abhijit Thakur" dsc="0" yomi="Abhijit Thakur">{0820590A-37D0-DC11-AA32-0003FF33509E}</primarycontactid>...

How to send an XML file to a Web Service (that records the XML file to HD)
I did this because I wanted to send an XML file to another computer, whether it be next to the one I’m using  or in another country. You will need to adapt my example in order for it to work as you want it. All I demonstrate here is that it is possible to send an XML file to another computer using XML Web Services. Let me know if it works for you. The code assumes you can use Visual Studio. Make the Web Service 1. Make a new project, choosing to make a Web Service. 2. In the code behind-page, place the code below. 3. Build the Web Service. Code: <WebMethod()>...

Xml serialization of a file in C#.Net
Hi All !Can anyone tell me how to serialize and deserialize a file (specially an image file) in XML using C#.NET ?...

"Error loading XML file :\windows\\framework\v1.0.3705"...does this mean v.1.1 code trying to run in a v.1.0 app?
I uploaded some new files into my existing third-party hosted site, including a .DLL into \BIN\, which is running AS.NET v.1.0. I got the following error message when browsing to one of the pages using the code in the namespace defined in the DLL: Error loading XML file c:\windows\\framework\v1.0.3705\Config\machine.config Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed. (c:\windows\\framework\v1.0.3705\Config\machine.config) ...

submitting an XMl file to a server, saving it as an XML file and reposting it to another url
I apologize in posting this - I kept looking in the forums but could' nt find a parallel - please point me in the right direction. 1. I need to upload an XML file to a server ( This is sort of complete) The code that has been used is <% Set xmlDoc = CreateObject("Msxml2.DOMDocument.5.0") Set xmlHTTP = CreateObject("MSXML2.ServerXMLHTTP.5.0") xmlDoc.validateOnParse = True xmlDoc.async = False xmlDoc.load("C:\Inetpub\wwwroot\test\PO.XML") ("POST", "", False) xmlHTTP.send(x...

Pulling data from one xml file based on values in a second XML file
Alright, I'm programming using vb within, but I'm a little bit of a newbie when it comes to xml. What I'm trying to do is display particular information from an XML file (parts.xml) based on information in another XML file (orders.xml). Ideally, I'd like to display the info using the xml control within and an xsl stylesheet. The setup of the files is that within parts.xml, each part has an id attribute. I'd like to grab the part id from the orders.xml file, and use it to extract only information on specific parts from parts.xml. Is there an easy way to do this? Any help...

Parsing XML file with 2005
Please help!! :)  I am trying to find a way to parse the following XML file. The problem I'm running into (I think) is that the fields have spaces in their name (i.e. Page ImportFileName).  I tried to do this with ASP about a year ago and didn't have any luck.  Now I'm trying to do it with VB.NET.  Any help is appreciated.  My current code is below the XML file.  Thanks!! Robert Lewis <PERMSBatchExport><Batch Name="100044 - dmw 349543783 1:17:51 PM eid:1508" CreationUserID="CPPSB019D" CreationDateTime="2004-04-13 15:46:56" CreationSiteName="IL_8ATAA"&...

Load XMl file and read xml file
How do I load and read nodes from the xml file in c#.??? ThankYou Sample code: Yang.NET Developer Here is how you read xml file and loop and display nodesXmlDocument xDoc = new XmlDocument();xDoc.Load(xmlPath); foreach(XmlNode node in xDoc.SelectNodes("//nodeName you want to display")){Response.Write("name: " + node.Attributes["name"].InnerText + " value: " + node.Attributes["value"].InnerText);}...

Web resources about - Microsoft Chart control for .NET Framework about state management and serialization problem, it works OK with one XML file but fails with another XML file -

Serialization - Wikipedia, the free encyclopedia
When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of ...

FlatBuffers 1.1: a memory-efficient serialization library
... in development, the FlatBuffers 1.1 update is here. Originally released in June 2014, it’s a highly efficient open source cross-platform serialization ...

Increase Java Serialization Performance
The simplest way to send and receive a Java object is to use an ObjectOutputStream/ ObjectInputStream object pair, but is it the most efficient ...

Jackson Data Binding Message Serialization
... ObjectMapper is simple: objectMapper = new ObjectMapper( new JsonFactory(); objectMapper.disableDefaultTyping(); objectMapper.disable(Se ...

Performance at Scale: SSDs, Silver Bullets, and Serialization
... occur when customers are trying to speed up the wrong thing. A common phenomena at the heart of the disappointing SSD outcomes is serialization. ...

LDS Serializations - Meridian Magazine - LDS, Mormon and Latter-day Saint News and Views
Meridian Magazine is the place where Latter-day Saints [LDS] gather online. Meridian is a values-based publication, drawing upon the standards, ...

Is Object Serialization Evil?
... to be the comparison of the various data stores, but the comparison of how data is stored. More specifically, I want to show the object serialization, ...

Serialization Vulnerabilities Put Many Android Devices at Risk
Researchers at IBM have identified vulnerabilities that can be exploited by malicious Android applications to escalate privileges, allowing cybercriminals ...

New Fall Shows Mix It Up by Adding Serialization, ‘Blacklist’-Style
One reason “The Simpsons” has run long enough to sustain an uninterrupted 12-day marathon is that nothing much changes around Springfield. The ...

Resources last updated: 12/23/2015 8:51:41 PM