views:

36

answers:

1

Hi,

I'm trying to prevent data from loading on the page when its needed.

Currently, I check the IsPostBack bool to prevent loading data in my user controls which allows the data to be loaded when the page is initially requested.

However, if my page fails validation and the page is sent back to the user with error messages, my user controls no longer have data in them because the initial request was a postback.

One solution is to have a flag in every user control (IsFailedPostBack) to force them to reload their data. Is there a better way?

A: 

Add the check if(!Page.IsValid) along with your PostBack conditional.

Joel Etherton
Didn't even think of that :) Thanks
Sir Psycho