Use System.Reflection to get page namespace

J

Joel Leong

How can I use Reflection to get full namespace of my web page?

I got a page under this namespace

namespace CompanyABC.Admin
{
public class FruitList: System.Web.UI.Page
{
}
}

Q1: When i try to use this.GetType().ToString, it returns
ASP.FruitList_aspx. but I want to get CompanyABC.Admin.FruitList.(When i
watch the object Page in the watch window, I can see
CompanyABC.Admin.FruitList under the [ASP.FruitList_aspx] tree node.) How
can I do that?

Q2: How to truncate CompanyABC so that I can get Admin.FruitList only?
 
J

Joel Leong

Page.GetType().BaseType.ToSTring();
Matt Berther said:
Hello Joel,

You could try this.GetType().Namespace...

--
Matt Berther
http://www.mattberther.com
How can I use Reflection to get full namespace of my web page?

I got a page under this namespace

namespace CompanyABC.Admin
{
public class FruitList: System.Web.UI.Page
{
}
}
Q1: When i try to use this.GetType().ToString, it returns
ASP.FruitList_aspx. but I want to get CompanyABC.Admin.FruitList.(When
i watch the object Page in the watch window, I can see
CompanyABC.Admin.FruitList under the [ASP.FruitList_aspx] tree node.)
How can I do that?

Q2: How to truncate CompanyABC so that I can get Admin.FruitList only?
 
G

Guest

HI Joel

Type t = typeof(FruitList);
t.FullName.ToString();

will you give full name of the class including namespace.

Do remember to include

using System.Reflection;

cheers,

Jerome. M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top