Intermittent IsPostBack/EventHandler problem

Discussion in 'ASP .Net Web Controls' started by ourwebstop@gmail.com, Mar 30, 2007.

  1. Guest

    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
     
    , Mar 30, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SiBNY0Q=?=

    EventHandler problem

    =?Utf-8?B?SiBNY0Q=?=, Feb 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    365
    =?Utf-8?B?SiBNY0Q=?=
    Feb 22, 2004
  2. Joey
    Replies:
    2
    Views:
    4,052
  3. Paul
    Replies:
    2
    Views:
    2,966
  4. J McD

    eVENThANDLER PROBLEM

    J McD, Feb 23, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    132
    Thomas Johansen
    Feb 23, 2004
  5. Problem with eventhandler in c#

    , Jan 23, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    177
Loading...

Share This Page