Page Load Does Not Run

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

Hello, I am walking through the ASP.Net book by Dino Esposito. I created a
new project and used the "add existing" option to add the files to my new
project. He had all of the code on a single page and I split into the form
and codebehind. I place a "break point" on the page load event and run the
project, but the break point never is hit. The code should display a grid,
and it shows up in the Design mode, but does not show up when I run. I
checked the page directive to ensure it was set up with the instruction to
indicate that I was using the code behind. When I import is as a single page
and run, it runs just fine. So I must not be setting something correctly to
cause it to go to the code behind form. What should I be looking for to find
out why the page load is not running when I run the application?

Here is my @Page directive..
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="GridInAction2.aspx.vb" Inherits="GridInAction.GridInAction2"%>
 
Since you're using AutoEventWireup="false", Page_Load won't be automatically
connected up as an event handler for the OnLoad event. Your either need to
do 1) AutoEventWireup="true", or 2) override OnLoad instead of using
Page_Load, or 3) override OnInit and do this.Load += new
EventHandler(Page_Load);. Personally I almost always choose option 2.
Visual Studio .NET does option 3 for you.
 
Back
Top