the more i think about it, i dont think that you can use namespaces in code files, since you are using a web site project.
with a web app project, all the code is compiled into an actual .dll library, whereas with a web site, the code is not compiled this way. since with a web app all the code is in one assembly, it can contain things like namespaces, but with a web site, the
code files are just code files, and since they are not in an assembly, they cannot be contained in things like namespaces.
from what ive been playing around with (i use web apps instead of web sites, so i dont know too much about their differences), it seems that the ASP namespace is an "on-the-fly" namespace. if you have two different pages, and look at the ASP namespace for
each, then you will find that they do not show the same things. by default, it looks as if for each page, their ASP namespace allows access to the current page for which you are working on. then, when you add Reference tags, the controls you reference for
that page become visible only in that pages ASP namespace. (this would explain why earlier, not all of the controls in the directory where you put them were visible in the ASP namespace).
as i said in my previous post, web sites are not compiled into an assembly. This would also mean that your web site project does not actually have a namespace to it.
Yeah, I've read into the Website-VS-Webapp bit, and see what you mean. Well, I edited my above post, that solution worked. The rules as I understand them:
The control needs to have a ClassName tag in the <%@ Control %> tag (actually, I think if it doesn't you'll use the generated class name?)
The page has to use a <%@ Reference %> tag in the .aspx file to reference the control
If page uses a code-behind file, the namespace "ASP" contains all controls reference with the <%@ Reference %> tag. If it's inline code, there's no need for this.
Again, thanks for all the help. Now, back to the problem that got me into this in the first place. I may have to make yet another post :S
EDIT: We're playing some weird post tag here. I read your other reply, yes thats right, all the controls reference and the actual page class itself, from what I can see.
The control needs to have a ClassName tag in the <%@ Control %> tag (actually, I think if it doesn't you'll use the generated class name?)
ClassName i believe will only override the name of the class as defined in the code-behind.
its good though that you've gotten this problem worked out. sorry i couldn't have given you a more direct answer from the beginning; i'm still in the learning stages with this stuff.
and, it probably would be a good idea to post a new thread for your other problem.
Marked as answer by aazizorg on May 22, 2009 03:45 PM
jzimmerman20...
Member
503 Points
183 Posts
Re: Using the class of a user control in code-behind
May 22, 2009 03:10 PM|LINK
the more i think about it, i dont think that you can use namespaces in code files, since you are using a web site project.
with a web app project, all the code is compiled into an actual .dll library, whereas with a web site, the code is not compiled this way. since with a web app all the code is in one assembly, it can contain things like namespaces, but with a web site, the code files are just code files, and since they are not in an assembly, they cannot be contained in things like namespaces.
jzimmerman20...
Member
503 Points
183 Posts
Re: Using the class of a user control in code-behind
May 22, 2009 03:19 PM|LINK
from what ive been playing around with (i use web apps instead of web sites, so i dont know too much about their differences), it seems that the ASP namespace is an "on-the-fly" namespace. if you have two different pages, and look at the ASP namespace for each, then you will find that they do not show the same things. by default, it looks as if for each page, their ASP namespace allows access to the current page for which you are working on. then, when you add Reference tags, the controls you reference for that page become visible only in that pages ASP namespace. (this would explain why earlier, not all of the controls in the directory where you put them were visible in the ASP namespace).
as i said in my previous post, web sites are not compiled into an assembly. This would also mean that your web site project does not actually have a namespace to it.
aazizorg
Member
3 Points
7 Posts
Re: Using the class of a user control in code-behind
May 22, 2009 03:22 PM|LINK
Yeah, I've read into the Website-VS-Webapp bit, and see what you mean. Well, I edited my above post, that solution worked. The rules as I understand them:
- The control needs to have a ClassName tag in the <%@ Control %> tag (actually, I think if it doesn't you'll use the generated class name?)
- The page has to use a <%@ Reference %> tag in the .aspx file to reference the control
- If page uses a code-behind file, the namespace "ASP" contains all controls reference with the <%@ Reference %> tag. If it's inline code, there's no need for this.
Again, thanks for all the help. Now, back to the problem that got me into this in the first place. I may have to make yet another post :SEDIT: We're playing some weird post tag here. I read your other reply, yes thats right, all the controls reference and the actual page class itself, from what I can see.
jzimmerman20...
Member
503 Points
183 Posts
Re: Using the class of a user control in code-behind
May 22, 2009 03:40 PM|LINK
ClassName i believe will only override the name of the class as defined in the code-behind.
its good though that you've gotten this problem worked out. sorry i couldn't have given you a more direct answer from the beginning; i'm still in the learning stages with this stuff.
and, it probably would be a good idea to post a new thread for your other problem.
aazizorg
Member
3 Points
7 Posts
Re: Using the class of a user control in code-behind
May 22, 2009 03:42 PM|LINK
I think I've got a work around for that problem that better suits the situation anyways.
You actually helped me a lot. I didn't know what kind of response I'd get on these forums, but so far looks pretty helpful, I'm glad I posted.