Reputation: 41
Can I declare namespaces in the web.config so that I don't have to write using
statements for each namespace in each of my codebehind files?
Upvotes: 4
Views: 2275
Reputation: 2411
You can do this for namespaces or common controls:
<system.web>
<pages>
<namespaces>
<add namespace="The.Namespace" />
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" etc... />
</controls>
</pages>
</system.web>
Upvotes: 1
Reputation: 65116
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="MyNamespace" />
</namespaces>
</pages>
</system.web>
</configuration>
Is this what you're looking for?
Upvotes: 3
Reputation: 1924
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<namespaces>
<add namespace="MyNamespaces.NamespaceName" />
</namespaces>
</pages>
</system.web>
</configuration>
MyNamespaces.NamespaceName will be now available for all of your pages in project.
cheers
Upvotes: 1