0

I am using web forms to develop a web application. From the very beginning, I have always been surprised by the page_load event being fired twice, and finally today I found out that all gridviews and texts are rendered after first page_load, and it takes another page_load to render all the dynamic asp.net charts..

why is it so, is there an attribute on the chart web server control that I can use to bypass this?

appenthused
  • 173
  • 1
  • 10
  • The page_load event should not be firing twice. The charts should render immediately. There must be something wrong in your code. Why don't you post a small sample that illustrates the problem? – Steve Wellens Nov 08 '11 at 17:58
  • protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Chart1Bind(); } } protected void Chart1Bind() { //fetching values for the charts Chart1.Series["Series1"].Points.DataBindXY(x1, y1); //formatting stuff comes here } – appenthused Nov 08 '11 at 18:47
  • Take the Chart1Bind function OUT of the IsPostBack clause. – Steve Wellens Nov 08 '11 at 20:52
  • I do not think so, because I tested without IsPostBack, it is the same story.. – appenthused Nov 08 '11 at 21:25
  • And I need IsPostBack since I am using AJAX UpdatePanel – appenthused Nov 08 '11 at 21:25

1 Answers1

0

Check to see if you "AutoEventWireup" set to true. If this is a control, check the parent control/page also. Even if the control itself is set to false, but the parent is set to true, it seems to fire anyway. Also check where you assign listener to Page_Load event:

this.Load += new System.EventHandler(this.Page_Load);

Should be in InitializeComponent method

Pavel Podlipensky
  • 8,201
  • 5
  • 42
  • 53