views:

270

answers:

2

I have a web user control (ascx) in my project and I would like to move it to a more general namespace that makes it easier to share the control across projects.

The problem is, it seems that web user controls like to stay in a namespace named after the web application they're in.

Is there some way to break out of the web app namespace?

Update: Looks like you can in C#, but it's not working in VB.Net.

A: 

Grr...looks like the answer is no.

http://msdn.microsoft.com/en-us/library/0dx91cw5%28VS.80%29.aspx http://stackoverflow.com/questions/479782/possible-to-override-vb-net-root-namespace

VB will automatically use the default namespace in any declaration. The only way around it seems to be to declare the default as blank and specify the namespace in every place.

Chris
A: 

The problem is not that of the namespace. The problem is that of the user control being tied up with an ascx file that needs to exist as a file in your web application.

There is no way to make a dll project that can contain the ascx file, and let the dll be shared between multiple web application projects.

Depending on the complexity of you control, you can perhaps make a "Custom Control". Here you don't have an ascx file, but you build up the HTML entirely in code. These can be placed in a dll that can be reused between web applications.

Pete
I'm willing to copy the ascx of the control over as an svn external or something similar, which resolves the ascx problem. The trouble is, in every project, I'll have to have a slightly different ascx that references the project name, because of the namespace dilemma in the question.
Chris