ASP.NET Page_Load values are lagging one postback behind -


i have foreach loop in page_load method of 1 page determine whether enable button or not.

code:

foreach (var class in classes) {     (var = studentslist.count - 1; >= 0; i--)     {         if (studentslist[i].id == class.student_id)             studenstlist.remove(studentslist[i]);     } } if (studentslist.count == 0) {     button1.enabled = false;     button1.text = "a"; } else {     button1.enabled = true;     button1.text = "b"; } if (page.ispostback) { return; } 

the issue:

the value of studentslist.count lagging behind postback. if after loop should 1, has value of 1 @ next postback. i've debugged confirm case.

you can move foreach loop page_preload method , give try.

here anof life cycle of asp.net page: http://msdn.microsoft.com/en-us/library/ms178472.aspx#lifecycle_events


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -