Issues with handing server events...

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?
 
B

bruce barker

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?
 
A

AC

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top