My situation: we have a project where an aspx page (which uses MasterPages and also uses Atlas) needs to contain WebParts that actually are UserControls, but which UserControls are available depends on the user and associated data, so a WebPart/UserControl that is available one day, might be considered off-limits for that user the next day.
So far, I've been unable to come up with a way to do this. Even simply adding UCs as WPs ain't working. Right now I do this in the Page_Load of the aspx page -- LoadControl, then CreateWebPart, then AddWebPart -- and while this works perfectly fine when I do this the first time, it falls apart after a postback: either the controls get added again and again on each postback, or they fail to capture the postback-event, etcetera. Ditto once the controls are saved in the Profile.
FYI: this cannot be a "static" solution. There needs to be the possibility to simply create a new UserControl, add the name in a database table, and then allow user-access to this control via a "security" framework. However, some controls also need to be subjected to other rules, i.e. they can only be accessed on certain days etc.
It all seems to work okay when the UCs get hardcoded in the aspx page, but that isn't a viable solution IMHO: the page would get cluttered with tags, and also we don't think it is wise to check the security settings in each UC. It would also remove the flexibility of the system we had in mind: i.e. any developer can create a UserControl, and after he/she adds it to the list of available controls (in the database), the admins can decide which user has access to the control.
I have searched these forums, but all I encounter are the same solutions that don't work for me. I would love to know whether this is even possible, or if I'm simply doing this the wrong way.
Life would be a lot easier if we could take a look at the source code.