ASP.NET: How to initialize when *user control* is initially loaded
Posted
by kendor
on Stack Overflow
See other posts from Stack Overflow
or by kendor
Published on 2009-04-30T21:04:45Z
Indexed on
2010/03/21
21:01 UTC
Read the original article
Hit count: 333
ASP.NET
|usercontrols
I have an ASP.NET user control that I'm embedding in another user control. This works fine.
I need to know the best logic/method for detecting when the control is loaded. In other words, I have some display initialization logic that needs to run when the control is initially displayed. Surely there is a pattern for this.
The typical method is to put (!IsPostBack) logic in the Page_Load method of the control. This works great until you end up with a state when the Parent page has already posted back many times. My user control gets added to the page but its display does not intialize properly.
I'm hoping to find a way that keeps this logic inside the control, versus various hacking around in the codebehind of the parent page.
© Stack Overflow or respective owner