I have an asp.net page with a task bar on the side. Clicking a task opens up a user control for that task with some controls and a close button.
How do I run some C# code when that user control is hidden by clicking the close button?
Much of the stuff on the control is surrounded by an update panel and I'll just say right now that I have to use it. Anyway, I would just use the page_unload event but this is called in many other instances than the one single instance I want it to be called in (window is closing) partly because of the updatepanel.
The close button is not something I've implemented, it's just part of the framework being used for these controls, so it doesn't have any code behind.
All I really want to accomplish is to have some C# code run only when the control is closed, which in effect just hides it. Is there something analogous to Page_Closing/Hiding? I can't seem to find it if there is.
Is there any way to achieve this?
EDIT: I should note that I did find the OnHide event for the control, but the code behind for this logic should really be in the controls, not the pages. Mainly because what needs to happen is when the control is hidden, set some text in the control so when it is loaded up later it will display the correct info.
EDIT: Thanks for all the insights. I'm still not really able to solve the problem, what teedyay suggested...
"If you don't want to handle that code on the page, make your own version of the control, inheriting from the original. You can handle the OnHide event in a more self-contained way in there."
Is probably the closest to what I need. I'm wondering if it is at all possible to bubble events from the parent to the user controls? Logically in my head it seems like it wouldn't be possible and I haven't found any info on it but I thought I'd ask.
Update:
I think stepping back and stating a little more clearly what I want to accomplish may clear up some confusion.
I have a user control that is a floating panel that hovers over my main page. It inherits from a control that I do not have the code for. This control generates URL's (upon user request) and displays them within the control it also shows a history of the last 3 URLS generated.
When the page recognizes the controls OnHide event being fired, I need the code within the user control to disable some buttons and store the url in a history queue. How can I get my user control to know when the parent hears an OnHide event?
Also, am I thinking about this wrong, if so is there a smarter way to do this?