473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Reflection in ASP.NET - Strange behavior?

I have the following code encapsulated in an ascx page (user control):

namespace MyCompany.Web.UserControls
{
[most of my code]
string webform_namespace = this.GetType().Namespace.ToString();
}

Now, when I run this and output the string to the trace information, I
get the following value:

"ASP"

However, I want the value to be "MyCompany.Web.UserControls", which is
the namespace where I've defined it...pretty much the way I'd expect
this to show up if I was running this as a Windows form.

Is there any way to do this? Why is the namespace showing up as
"ASP"? Is this a default value? If so, is there any way to override
this?

Thanks,
-Justice
Nov 17 '05 #1
1 1257
Justice,

You need to check the Namespace of the base type. Change your code to this:

string webform_namespace = this.GetType().BaseType.Namespace.ToString();
Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: ju**********@hotmail.com (Justice Gray)
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Reflection in ASP.NET - Strange behavior?
Date: 15 Oct 2003 09:08:54 -0700
Organization: http://groups.google.com
Lines: 23
Message-ID: <56*************************@posting.google.com>
NNTP-Posting-Host: 64.42.208.35
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1066234135 16770 127.0.0.1 (15 Oct 2003 16:08:55 GMT)X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Wed, 15 Oct 2003 16:08:55 +0000 (UTC)
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnew s1.google.com!no
t-for-mailXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:184351
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I have the following code encapsulated in an ascx page (user control):

namespace MyCompany.Web.UserControls
{
[most of my code]
string webform_namespace = this.GetType().Namespace.ToString();
}

Now, when I run this and output the string to the trace information, I
get the following value:

"ASP"

However, I want the value to be "MyCompany.Web.UserControls", which is
the namespace where I've defined it...pretty much the way I'd expect
this to show up if I was running this as a Windows form.

Is there any way to do this? Why is the namespace showing up as
"ASP"? Is this a default value? If so, is there any way to override
this?

Thanks,
-Justice


Nov 17 '05 #2

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

Similar topics

1
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of...
0
by: CLEAR-RCIC | last post by:
Hi All: I have a .dll that deserializes a class. When I call this .dll from an .exe it works fine. When I call the .dll using reflection (calling the .dll on the fly) I get an error on the...
0
by: MWells | last post by:
I have a simple VS.NET solution with Project "A" as a web app and Project "B" as a class library. "B" does some HTML rendering, and uses reflection to locate and load the necessary rendering...
1
by: Alexander Inochkin | last post by:
Hi! I found same strange behavior of ASP.NET. It is possible this is the bug. Follow the steps:
1
by: Patrick | last post by:
Has been trying to get an ASP.NET DLL's modification date/time for the "release date/time" to be displayed on the page's footer Using: System.Reflection.Assembly...
0
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
1
by: Nicholas Palmer | last post by:
Hi all, Got a question about the AspCompat=true page property. First a little background. We have an ASP.NET app that uses two COM components. The first is the Microsoft OWC 11 components and...
2
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have an asp.net web page (say page.aspx) which derives from a custom base page object (CustomPage : BasePage : System.Web.UI.Page) Which has a method called DoSomething(params). My web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.