By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,852 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,852 IT Pros & Developers. It's quick & easy.

Access Page's local resource from user control

P: n/a
Is it possible to get access to the local resource
(App_LocalResources) 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_LocalResources
folder.
Can someone help me please?

Cheers, Hannes

Apr 16 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sc*******@rehm.de schrieb:
Is it possible to get access to the local resource
(App_LocalResources) 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_LocalResources
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 GetPageLocalResourceObject(string
resourceKey); // the delegate declaration itself
public GetPageLocalResourceObject LoadLocalPageResource; // 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>.LoadLocalPageResource =
GetLocalResourceObject; // set the user control's delegate instance to
my own GetLocalResourceObject function
Master.LoadLocalPageResource = GetLocalResourceObject; // set the
master page's delegate instance to my own GetLocalResourceObject
function

HTH!

Apr 17 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.