Intermittent IsPostBack/EventHandler problem

O

ourwebstop

I have a page with a datagrid that gets built during Page_Load().
Below the datagrid is a button: <asp:button id="btnUpdateGrades"
runat="server" Width="101px" Text="Save Grades"></asp:button>

I initially had an event handler on the button that was initialized
like this in IntializeCompenent():
this.btnUpdateGrades.Click += new
System.EventHandler(this.btnUpdateGrades_Click);

That event handler was occasionally not being called. It was first
reported by our users on the production server, and I was later able
to (occasionally) reproduce it on my localhost under the Visual Studio
debugger by clicking the button with a breakpoint in the handler and
occasionally not reaching the breakpoint.

I then removed the event handler and simply called the btnUpdateGrades
function from within Page_Load() like this:
if(this.IsPostBack)
{
btnUpdateGrades_Click();
}

I still have intermittent problems -- When I click the button, the
page reloads. But roughly 1/8 of the time, IsPostBack is false.
Again, I can see this in the debugger. While I follow the exact same
steps each time, IsPostBack is true about 7/8 of the time, and
IsPostBack is false 1/8 of the time.

Ideally, I'd like to hook up the eventHandler and have it work that
way. I'm not sure if the problem with the eventHandler being called
inconsistently and the problem with the IsPostBack being set
inconsistently is the same problem or not -- I'm suspecting it is.
I'm not sure how to troubleshoot this further.

I'd be grateful for any help or pointers.

Brian McLaughlin
Administrative Computing
George Fox University
(503) 554-2587
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top