Issues with handing server events...

  • Thread starter Thread starter AC
  • Start date Start date
A

AC

I have a page where I'm displaying articles based on the current year selected. My page dynamically builds a few links at the top to select a different year than the current one selected (the current year is not shown as an option). Then, based on the year selected, I am performing some specific logic to display the articles. By default, the first time the page loads, I default to the current year.

Within my Page_Load, I have the following:
If Not IsPostBack Then
_currentYear = Year(DateTime.Now)

' display the current year selected (Literal control)
CurrentArchiveYear.Text = _currentYear.ToString()

' build the year selection menu
BuildArchiveMenu()

' build news items
BuildArchiveNewsList()
End If

When it loads the very first time, everything works just fine (the display that is). But when someone clicks on one of the year selectors in the menu (LinkButton controls with a bound event), the event isn't fired. I moved some things around (took everything out of the IF stmt above except the _currentYear line ant put it after the IF) to make sure it was firing and it was, but it seems the Page_Load is firing BEFORE my event handler as my page was loading without error, but the articles weren't being written (because it wasn't getting the current year from the event handler).

I must be doing something wrong with my order of events... ideas?
 
page load fires before any events, read the documentation on the page lifecycle.

-- bruce (sqlwork.com)

I have a page where I'm displaying articles based on the current year selected. My page dynamically builds a few links at the top to select a different year than the current one selected (the current year is not shown as an option). Then, based on the year selected, I am performing some specific logic to display the articles. By default, the first time the page loads, I default to the current year.

Within my Page_Load, I have the following:
If Not IsPostBack Then
_currentYear = Year(DateTime.Now)

' display the current year selected (Literal control)
CurrentArchiveYear.Text = _currentYear.ToString()

' build the year selection menu
BuildArchiveMenu()

' build news items
BuildArchiveNewsList()
End If

When it loads the very first time, everything works just fine (the display that is). But when someone clicks on one of the year selectors in the menu (LinkButton controls with a bound event), the event isn't fired. I moved some things around (took everything out of the IF stmt above except the _currentYear line ant put it after the IF) to make sure it was firing and it was, but it seems the Page_Load is firing BEFORE my event handler as my page was loading without error, but the articles weren't being written (because it wasn't getting the current year from the event handler).

I must be doing something wrong with my order of events... ideas?
 
Thanks... was having trouble locating the order of events on rendering an ASP.NET page... lifecycle was the search keyword I needed.
page load fires before any events, read the documentation on the page lifecycle.

-- bruce (sqlwork.com)

I have a page where I'm displaying articles based on the current year selected. My page dynamically builds a few links at the top to select a different year than the current one selected (the current year is not shown as an option). Then, based on the year selected, I am performing some specific logic to display the articles. By default, the first time the page loads, I default to the current year.

Within my Page_Load, I have the following:
If Not IsPostBack Then
_currentYear = Year(DateTime.Now)

' display the current year selected (Literal control)
CurrentArchiveYear.Text = _currentYear.ToString()

' build the year selection menu
BuildArchiveMenu()

' build news items
BuildArchiveNewsList()
End If

When it loads the very first time, everything works just fine (the display that is). But when someone clicks on one of the year selectors in the menu (LinkButton controls with a bound event), the event isn't fired. I moved some things around (took everything out of the IF stmt above except the _currentYear line ant put it after the IF) to make sure it was firing and it was, but it seems the Page_Load is firing BEFORE my event handler as my page was loading without error, but the articles weren't being written (because it wasn't getting the current year from the event handler).

I must be doing something wrong with my order of events... ideas?
 
Back
Top