Why doesn't PageLoad(..) get called?
-
I'm running this project in Visual Studio .NET 2003 and when I click on this one page within my website, the PageLoad method in my code behind (myPage.aspx.vb) doesn't get called. Another method in the class DOES get called however. I set a break point in PageLoad but it is never reached. Also PageLoad sets a few global members but are not affected when the other method is called. Is this a bug in VS? Or some setting i'm missing?
-
I'm running this project in Visual Studio .NET 2003 and when I click on this one page within my website, the PageLoad method in my code behind (myPage.aspx.vb) doesn't get called. Another method in the class DOES get called however. I set a break point in PageLoad but it is never reached. Also PageLoad sets a few global members but are not affected when the other method is called. Is this a bug in VS? Or some setting i'm missing?
Check your
InitializeComponent
method. Is there a line hooking the Load event? It will look like:this.Load += new System.EventHandler(this.Page_Load);
If not, you will need to add one. There is one added by default, but I have seen cases where Studio removes it when controls are moved or renamed. It's been extremely rare in my experience (like once or twice), but I have seen it happen to others as well.The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
-
I'm running this project in Visual Studio .NET 2003 and when I click on this one page within my website, the PageLoad method in my code behind (myPage.aspx.vb) doesn't get called. Another method in the class DOES get called however. I set a break point in PageLoad but it is never reached. Also PageLoad sets a few global members but are not affected when the other method is called. Is this a bug in VS? Or some setting i'm missing?
-
Thanks for your replies!! I managed to get it working on my own. However the two suggestions to the problem wouldn't work. The first one this.Load += new System.EventHandler(this.Page_Load); I think only applies to C#. I'm trying to get a forums VB project to run. I believe that the InitializeComponent method is usually hidden in VB projects in VS .NET so that's why i couldn't get it to work. The AutoEventWireup=true (instead of the default being = false) is only a performance switch. I think it allows you to manually trigger events instead of automatically triggering them. To fix my problem, I noticed that my Page_Load method was defined as Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) instead of Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ..that worked. Thanks for your responses though!!