I am writing a replacement for the sharepoint asset picker dialog with additional features.
There is a requirement to browse media libs which are located in other site collections. So I added a configuration page where you can add the URLs to the media libs to the sharepoint property bag.
In the custom AssetPicker dialog I added the SPList objects created from the configured URLs to a member List called medialibs.
I know that it is very important to dspose the SPWeb and SPSite the SPList object belongs to. I do that in the OnUnload event of the page, but discovered that OnUnload is calld every time on postback. I can't rebuild the medialibs list every time in OnLoad because there is a treeview control on the page which holds references to the SPList objects in medialibs. If I dispose and rebuild them, the objects are new and different. The treeview cannot be rebuilt every time, because it would lose the information which nodes are opened.
How do I persist the contents of the medialibs over postback? How do I ensure the SPList objects in medialibs are properly disposed when the user leaves the page?
Thanks!