base user control with ReadWriteAuthorization?

base user control with ReadWriteAuthorization?

Old forum URL: forums.lhotka.net/forums/t/1846.aspx


DansDreams posted on Monday, November 27, 2006

I'm kind of treading new water for me here... I like to put as much functionality as possible into base forms and user controls... and working with the ReadWriteAuthorization component I got this bright idea that there's a some common code regarding the use of this thing that could be in a base user control.  (Well, it's not really a LOT of code, but I also put the basic functionlality like CRUD buttons in that base control and it's significant when you add all that up.)

The inner workings of extender controls is a bit of a stretch for me, but it doesn't seem possible to slap the ReadWriteAuthorization on this base user control and have it work in the designer on inherited user controls.  At least, the ApplyAuthorization property doesn't appear in the property grid for any of the controls.

So, before I spend any time trying to make something work that never will, can anyone verify that's the case?

xal replied on Monday, November 27, 2006

I don't know if this will do it for you, but I experienced similar issues in an entirely different scenario, but still it may be related.

Let's get straight to it. Try handling form_load and do this:

If Me.DesignMode Then
    Me.Site.Container.Add(<your auth object>, <auth object name>)
End If

I hope it works...

Andrés

DansDreams replied on Tuesday, November 28, 2006

The form_load doesn't seem to be firing in the designer anyway, and as you may already know you can't do this in the constructor because the Site isn't set at that point.

So I may just need to declare abstract members in the base class and add the actual component in the final user control or form.

DansDreams replied on Tuesday, November 28, 2006

No, silly me I forgot the VS designer pukes on abstract classes.  Grrr.

xal replied on Tuesday, November 28, 2006

Take a look at this:

http://forums.lhotka.net/forums/thread/341.aspx

It allows abstract base classes and even with generics.
In there I use form_load to add inherited controls to the site...


I hope that helps

Andrés

Copyright (c) Marimer LLC