468,784 Members | 1,564 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,784 developers. It's quick & easy.

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 "TextResources" (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 1115
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**************@TK2MSFTNGP11.phx.gbl...
In my Page_Load event of all my web app Pages and UserControls I instantiate the same library class "TextResources" (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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by martin | last post: by
2 posts views Thread by Alex Maghen | last post: by
1 post views Thread by Ashutosh | last post: by
4 posts views Thread by Christopher | last post: by
3 posts views Thread by Peter Rilling | last post: by
10 posts views Thread by =?Utf-8?B?RGFuaQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.