views:

111

answers:

2

In a normal user control, we have .cs.ascx (code-behind) to assign the namespace we want our control to be in. But what if we don't have this code-behind to assign the namespace? Can we maybe assign the namespace of a user control in the headers?

EDIT I was hoping I can do somthing like this:

<%@ Control Language="C#" AutoEventWireup="true" Namespace="ThisIsTheNamespaceIWantMyControlToBeIn.Controls" %>
<b>Hello World!</b>
A: 

<%@ Control %> and <%@Reference %> tags with the tag namespace in the reference of the receiving page? I'm not sure if that fits what you're asking for.

phoebus
+1  A: 

I think that what you are asking for makes no real sense. The namespace that is specified in the code-behind file is the namespace for that class in the code behind file.

The code in the .ascx file is dynamically compiled into a new class that derives from the class in your code behind file. But this class is placed in a completely different namespace (I think that it will be in a namespace named ASP)

So if you don't have a code-behind file (I didn't even think that would be possible) then there is nothing to set the namespace for.

Pete
Yes you're right. Well the intent of this question is to see if I can get my controls registered in web.config <system.web><pages><controls> without having code-behind in my ascx file. Maybe that should have been a better question to ask.
burnt1ce