Retain Chart On PostBackThis question may be a fairly common one, but I don't seem to be able to find a solution.<br/><br/>I have a simple chart that I am populating in code based on the user who is viewing the website. My problem is that the Chart becomes blank after a post-back on the page. Assuming that I was initializing some data in the asp code, I shifted all my initializations (visual appearance etc) to C# code.<br/><br/>My aspx page contains just<br/> <pre lang=x-aspx>&lt;asp:Chart ID=&quot;ChartUserPoints&quot; runat=&quot;server&quot; Height=&quot;247px&quot; Width=&quot;382px&quot; style=&quot;margin-right: 0px&quot;&gt;&lt;/asp:Chart&gt;</pre> <p>I have ViewState set to Default. But on each postback, my viewstate data is null. I am using temp file configuration in web.config with timeout = 20 (if that matters)<br/><br/>Could someone please help me solve this problem?</p>© 2009 Microsoft Corporation. All rights reserved.Mon, 13 Jul 2009 05:37:06 Z0695de25-d20a-49be-94c0-554677b040e0http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/0695de25-d20a-49be-94c0-554677b040e0#0695de25-d20a-49be-94c0-554677b040e0http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/0695de25-d20a-49be-94c0-554677b040e0#0695de25-d20a-49be-94c0-554677b040e0Ohilhttp://social.msdn.microsoft.com/Profile/en-US/?user=OhilRetain Chart On PostBackThis question may be a fairly common one, but I don't seem to be able to find a solution.<br/><br/>I have a simple chart that I am populating in code based on the user who is viewing the website. My problem is that the Chart becomes blank after a post-back on the page. Assuming that I was initializing some data in the asp code, I shifted all my initializations (visual appearance etc) to C# code.<br/><br/>My aspx page contains just<br/> <pre lang=x-aspx>&lt;asp:Chart ID=&quot;ChartUserPoints&quot; runat=&quot;server&quot; Height=&quot;247px&quot; Width=&quot;382px&quot; style=&quot;margin-right: 0px&quot;&gt;&lt;/asp:Chart&gt;</pre> <p>I have ViewState set to Default. But on each postback, my viewstate data is null. I am using temp file configuration in web.config with timeout = 20 (if that matters)<br/><br/>Could someone please help me solve this problem?</p>Thu, 02 Jul 2009 09:36:43 Z2009-07-02T09:41:17Zhttp://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/0695de25-d20a-49be-94c0-554677b040e0#d6ef2acb-5cca-45dd-8678-85acc1f0e1afhttp://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/0695de25-d20a-49be-94c0-554677b040e0#d6ef2acb-5cca-45dd-8678-85acc1f0e1afDelianThttp://social.msdn.microsoft.com/Profile/en-US/?user=DelianTRetain Chart On PostBackEnable view state in the aspx page - EnableViewState have to be set before page load stage: <div><span style="font-family:Verdana, Arial"> <pre style="list-style-type:none;text-decoration:none;font-size:1.25em;padding:0px;margin:0px;border:initial none initial"><span style="color:#0000ff"><br/></span></pre> <pre style="list-style-type:none;text-decoration:none;font-size:1.25em;padding:0px;margin:0px;border:initial none initial"><span style="color:blue">&lt;</span><span style="color:#a31515">asp</span><span style="color:blue">:</span><span style="color:#a31515">Chart</span> <span style="color:red">ID</span><span style="color:blue">=</span><span style="color:blue">&quot;ChartUserPoints&quot;</span> <span style="color:red">runat</span><span style="color:blue">=</span><span style="color:blue">&quot;server&quot;</span> <span style="color:red">Height</span><span style="color:blue">=</span><span style="color:blue">&quot;247px&quot;</span> <span style="color:red">Width</span><span style="color:blue">=</span><span style="color:blue">&quot;382px&quot;</span> <span style="color:red">style</span><span style="color:blue">=</span><span style="color:blue">&quot;margin-right: 0px&quot; <span style="color:red">EnableViewState=&quot;True&quot;</span></span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">asp</span><span style="color:blue">:</span><span style="color:#a31515">Chart</span><span style="color:blue">&gt;</span></pre> <pre style="list-style-type:none;text-decoration:none;font-size:1.25em;padding:0px;margin:0px;border:initial none initial"><span style="color:#0000ff"><br/></span></pre> <pre style="list-style-type:none;text-decoration:none;font-size:1.25em;padding:0px;margin:0px;border:initial none initial"><span style="color:#0000ff"><br/></span></pre> </span></div>Tue, 07 Jul 2009 16:53:18 Z2009-07-07T16:53:18Z