sc*******@rehm. de schrieb:
Is it possible to get access to the local resource
(App_LocalResou rces) of an aspx page from within a user control
located somewhere else? I have created a user control which I want to
add to a page and read values from the page's local resource. But
within the code of the user control, I can only access the local
resource of the user control itself in its own App_LocalResour ces
folder.
Can someone help me please?
Cheers, Hannes
I found a satisfactory solution myself: The magic word is "delegate".
For those who are interested, here's some sample code. It is very easy
to implement.
In the content page's master page respectively the user control it
contains you put the delegate declaration:
public delegate object GetPageLocalRes ourceObject(str ing
resourceKey); // the delegate declaration itself
public GetPageLocalRes ourceObject LoadLocalPageRe source; // public
instance of the delegate to be set by the content page
Now in every content page, you have to put one or both of the
following lines into its Page_Load function (depending on whether you
use a master page or a user control or both):
<Instance of the User Control>.LoadLo calPageResource =
GetLocalResourc eObject; // set the user control's delegate instance to
my own GetLocalResourc eObject function
Master.LoadLoca lPageResource = GetLocalResourc eObject; // set the
master page's delegate instance to my own GetLocalResourc eObject
function
HTH!