Wednesday, March 28, 2012

Why isnt Page_Init and Page_Load being called?

Yes, THREE posts. And all I'm trying to do is move one application from 1.1 to 2.0. I see now that 2.0 uses partial classes...which IMO, just 'hides' more information that makes it harder for a programmer to learn it.
1. For instance. When I define a dropdownlist or label in my web page (.aspx) file, WHERE is this DEFINED? I don't see any...
Dim ddlDropDownList1 As DropDownList
In the default.aspx.vb file. So WHERE is it? Why is it being hidden? And in WHAT file is it being hidden? This is just one way that this new 2.0 will drive away new programmers in droves. If they can't *SEE* something, they won't understand how it works. If someone could explain to me where these defs are located and also why they are hidden. If the answer is to 'make it easier' I will shake my head.

2. Why, when I make breakpoints like the following in my webpage, are they never accessed?Partial Class _Default : Inherits System.Web.UI.Page

''' Capture the Page_Init event.
'''
-->BREAKPOINTHERE Private Sub Page_Init(ByVal source As Object, ByVal e As System.EventArgs)
-->BREAKPOINTHERE Dim szpath As String = ""
-->BREAKPOINTHERE If Not Page.IsPostBack() Then
My.Log.DefaultFileLogWriter.BaseFileName = "AnyLog"
szpath = My.Log.DefaultFileLogWriter.FullLogFileName()
End If
End Sub

''' Capture the Page_Load event.
''' The source object.
''' Event arguments.
'''
-->BREAKPOINTHERE Private Sub Page_Load(ByVal osource As Object, ByVal oeventargs As System.EventArgs)
-->BREAKPOINTHERE If Not Page.IsPostBack() Then
'ddlLivePages
End If
End Sub

So in essence, the Page_Init and Page_Load events are now worthless? Can someone explain to me why these events are not being caught? Thanks in advance. I feel sorry for anyone learning this from scratch. Way too many things that used to work and do not work anymore...Oh, and I may as well mention this too. Um, your forums DOESN'T WORK with Mozilla/Firefox. But then, this is part and parcel of the problem with Microsoft these days. Cross-browser is critical to real-life. Microsoft proponents and employees need to realize this. And having an asp.net forum that doesn't work for Firefox or any browser except IE...well, that's like putting a bag over one's head.
<br
UPDATE: Okay, I figured out the problem with the events. For future folks, you need to add:
<BR><BR
Handles MyBase.Load and Handles MyBase.Init

But I googled this, and there are a TOTAL of 174 threads about this. Way for M$ to explain the new differences. *Shakes Head* And that doesn't answer the other issues with M$. They really need to get their head out of the sand. And as much as I appreciate ASP.NET (this forum), I find it abysmal that you have not bothered to make this site cross-browser friendly in the 5 years you've been running this site. It's a symptom of a much larger problem...

1) If you look at the class declaration you will see that its a partial class - what used to be in InitializeComponent() is now in the other half of the partial class thats built by the designer

2) Have you double clicked on the page to recreate the link to the page_load and page_init events or gone into the page properties to make sure that they are pointing to the right place?


checkout the page directive autoeventwireup
set to false means you the designer will handle wiring up the event with a "Handles..." clause
set to true means IDE hooks up the events - so no "Handles..." clause needed

uncleb:

checkout the page directive autoeventwireup
set to false means you the designer will handle wiring up the event with a "Handles..." clause
set to true means IDE hooks up the events - so no "Handles..." clause needed

Ah. Words of wisdom. Thanks much Uncle B. That explains it! I did add the Handles and it worked, but I truly appreciate you spending the time to explain *why* this was happening...

0 comments:

Post a Comment