views:

17

answers:

2

I have an aspx page with several user controls (ascx) as well as an asp:button for signing out.

The click event of the button clears the session and does a response.redirect to the login page.

However, before the click event is called, since the page posts back, all of the Page_Load events run for all of the controls.

What is the best way to have the click event code run without unnecessary reloading of all user controls?

+1  A: 

The easiest way would be to add:

if(!IsPostBack)

around your control initialization in Page_Load.

klausbyskov
A: 

Make your logout button a link to a logout page that performs the session clear on page_load rather than it being a postback. That way the underlying page will never have to re-load.

Robin Day