473,799 Members | 3,298 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deduce calling Page or UserControl in library method

In my Page_Load event of all my web app Pages and UserControls I instantiate
the same library class "TextResour ces" (to take care of reading presentation
text strings from localizable resource files).

Within this class's constructor I want to deduce the name of the calling
control without having to pass it in. As this can either be a Page or a
UserControl I cannot use Request.URL since this only gives you the current
page.

Any ideas ?
Nov 18 '05 #1
1 1276
I know of no way to accomplish this, so I am going to suggest what you are
trying not to do (apologies, although the method may be slightly different
than you were thinking). My suggestion is to create another constructor and
try something like:

public MyClass(object caller)
{
}

and call like so:

MyClass mc = new MyClass(this);

You can then determine the page or control calling the class.

I took a little time to experiment and I cannot find a way of either
a) deriving from a class that knows its container
b) determining calling assembly from runtime

If there is a way, reflection is probably where it is located.

Good luck!

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** ***
Think Outside the Box!
*************** *************** *************** ***
"JezB" <je**@somewhere .com> wrote in message
news:ez******** ******@TK2MSFTN GP11.phx.gbl...
In my Page_Load event of all my web app Pages and UserControls I instantiate the same library class "TextResour ces" (to take care of reading presentation text strings from localizable resource files).

Within this class's constructor I want to deduce the name of the calling
control without having to pass it in. As this can either be a Page or a
UserControl I cannot use Request.URL since this only gives you the current
page.

Any ideas ?

Nov 18 '05 #2

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

Similar topics

6
11304
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
2
1760
by: Alex Maghen | last post by:
I have a site where most of the pages will have a common "shell" or layout. There will be an outer table which will hold HTML elements but which will *also* hold UserControls (Global Nav, etc.). Right now, all of the HTML and the @ Register directives for the shell's UserControls are copied onto each and every .ASCX page on the site I find this kind of frustrating because it means that I have to change many files whenever I want to make...
1
1978
by: Ashutosh | last post by:
HI Friends, I have a usercontol where i have one public which i want to call in wizard..... in in wizard second page i have implemented a usercontrol and on last page of wizard i have to call that usercontrol method....but i m getting an error "Object reference not set to an instance of an object" So any solution???
4
7849
by: Christopher | last post by:
I am trying to load a UserControl which inherits from one of our customer classes which in turn inherits from UserControl. We use Page.LoadControl() from within our ASP.NET pages to load these controls but would like to also execute them form within a class not necessarily with a Page reference. Is there a way with Reflection or any other method of executing a UserControl without a specific page reference? Is it possible to create a new...
3
2354
by: Peter Rilling | last post by:
Okay, I am probably missing something simple so here is my problem. I have a page. On this page I have a usercontrol. On this user control I have another usercontrol. On each usercontrol I override the LoadViewState and SaveViewState methods. Now, the first time the page loads (non postback) the SaveViewState methods for both fire. When the form posts back, I would expect the LoadViewState to fire for both, but instead the only one...
1
6873
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle and page loading/rendering lifecycle.... Ok, now for the question: I have an ASPX page (page.aspx), and I have a UserControl (control.ascx). The UserControl has one textbox on the control, and one button control. I have added a public property...
9
3195
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will load with different data (locations, departments, etc.).
10
2431
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
10
2148
by: =?Utf-8?B?RGFuaQ==?= | last post by:
Hi, Trying to create a master page that holds a menu, and the menu switches between pages in the site. 2 problem arrosed: a. When I navigate from page to page (all AJAX Web Forms, with the Master pages as their master...) the entire page is refreshed - also the menu which belongs to the master, how can I fix it - so only the inside content will be refreshed ?
0
9688
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
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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
10243
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,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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
5467
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...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
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.