Solved

ASP.NET postback problem

Posted on 2004-03-25
1
420 Views
Last Modified: 2012-06-21
Hi,

I am using the Carlos Web Chart Control on my aspx page, but everytime a postback occurs the Chart(rendered as an image) disappears.

//using this code the Chart disappears in postback
void Page_Load()
{
    if(!Page.IsPostBack)
    {
      CreateChart();
    }
}

//so I'm using this code which works but is unefficient...
void Page_Load()
{
      CreateChart();
}

//maybe this piece of code may also be helpfull in your solution
void CreateChart()
{
    LineChart chart = new  LineChart();
    chart.DataSource = GetDataSet().Tables[0].DefaultView;
    chart.DataXValueField = "Time";
    chart.DataYValueField = "Wavelenght";
    chart.LineMarker.Size = 0;
    chart.Line.Color=System.Drawing.Color.Blue;
    chart.Line.Width=2;
    chart.DataLabels.ForeColor = System.Drawing.Color.Blue;
    chart.DataBind();
    ChartControl1.Charts.Add(chart);
    ChartControl1.RedrawChart();
}



0
Comment
Question by:Raab314159
1 Comment
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 250 total points
ID: 10676239
Raab314159,
If the created component is created dynamically, you need to re-create the chart for every postback unless you only deal with viewstate problems only. If the used component is static, you only need to make sure EnableViewState=True.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pass url parameter as session 9 48
Classic ASP - SQL Server connection problem Part 2! 3 53
Issue with Loop 4 50
Need help to rewrite script 3 68
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now