473,671 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Page's local resource from user control

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

Apr 16 '07 #1
1 3619
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!

Apr 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2399
by: vincentw56 | last post by:
This is the first time I have tried this. What we have is a com object the generates keys. A developer here wrote a .Net wrapper in C# for this com object. I am trying to call her dll wrapper with my ASP.NET page and I get an access denied error. I can use the test Windows Form just fine, but not my ASP.NET form. This is all local to my machine. The error is below. Thanks. Vincent Here is the error that I get:
1
1571
by: Jeremy | last post by:
Hi, I hope (expect!) this is straightforward - at this stage I need to know the feasibility of this. The scenario: a webserver running a database. A subset of the data (say 3 tables) needs to be loaded into an access database on a private serve someplace else (private LAN). My initial thoughts are: - generate from webserver database .csv formatted files (incrementals) - automatically ftp these to remote machine
3
3489
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no site that has this prohibition, and I have uploaded DAPs to various sites and used them from those sites. I do not understand why any site manager would prohibit DAPs. To the best of my knowledge DAPs, as HTM files, are merely hosted on the...
0
1491
by: Goran | last post by:
Hi I have created a very simple ASP.Net application that only consists of a CrystalReports Viewer, that has been connected to a .rpt file. When the page is loaded in the browser, the following message is shown: ************ Message ************** Access to the path "C:\Program\Microsoft Visual Studio .NET\Crystal Reports\Viewers\dynamic_images" is denied.
2
18929
by: Brent Burkart | last post by:
I am trying to send an email using SMTP server through IIS. I am recieving the following error. Access is denied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: Access is denied.
2
3018
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
5
3104
by: Dave Kolb | last post by:
Is there any other solution for an ASPNET application to access network resources other than running as SYSTEM, using delegation (a nightmare to get to work) or the COM+ solution? I cannot seem to impersonate a user and obtain network credentials using the DuplicateTokenEx call with appropriate parameters even though the call seems to not fail. I check my identity has changed but can only still do local commands. I would consider...
4
2820
by: Scott Shuster | last post by:
Hi, I've been searching and testing and have not yet found the answer I'm looking for. I have an ASP.NET (vb) application with an ecommerce function. When the user submits the page, I DON'T want them to be able to click on the 'BACK' button and get back to the form - they may inadvertently re-submit the page and get charged again. I WANT them to get the "Page has expired" message.
1
8978
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA which is a webserver running Win2k3 with IIS6, my domain account is a local administrator on this machine. The web app I am running is trying to write a file to ServerB which is also a Win2k3 machine. On the folder of the machine I am writing to...
0
8478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8821
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8599
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7439
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.