Solved

ASP.NET postback problem

Posted on 2004-03-25
1
418 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

13 Experts available now in Live!

Get 1:1 Help Now