• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

import namesapces in webconfig net 3.5 app and VB.net

is there a way i can import a namespace and my codebehind will see it right away so i dont have to add it on top of every codebehind page using VB.net  and asp.net 3.5 ?
0
Wigging
Asked:
Wigging
  • 6
  • 5
2 Solutions
 
CCongdonCommented:
According to MSDN:
The scope of a using directive is limited to the file in which it appears.
0
 
WiggingAuthor Commented:
so it must be added on top of each codebehind page?  

for instance  i use   Imports wmUtilities   all over my app.  
cant be just added in webconfig once?  
0
 
guru_samiCommented:
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
WiggingAuthor Commented:
i knew that.....i wanted to save siome time but i guess we are all on same boat :)
0
 
CCongdonCommented:
OK, I think I misunderstood. Import is a little different from 'using'. Have you tried putting your code in the App_Code directory (Or the Bin directory if it is a DLL)? That should cause a global import of the namespace into your project, allowing you to go to each page and call MyNamespace.MyClass.MyMethod without an import statement.
0
 
WiggingAuthor Commented:
my dll is in the bin directory.......what else do i have to do?  
0
 
CCongdonCommented:
If the code in the DLL is correctly written with a namespace around it... you shouldn't have to do much else now except to just fully call your objects. You'll have to use the full Namespace.Class.Method/Property call to get to them, but you can shortcut that with using diretives....which would then have to go on each page...
0
 
WiggingAuthor Commented:
i understand that.  

on top of my codebehind  i have

Imports wmUtilities



is there a way to not add this everytime?
0
 
CCongdonCommented:
OK, now I get it. I was thinking C#'s #Import directive.
Try adding this to the System.Web in your web.config:

  <pages>
    <namespaces>
      <add namespace="MyNameSpace" />
    </namespaces>
  </pages>
According to MSDN:
The namespaces element defines a collection of import directives to use during assembly pre-compilation. This attribute corresponds to the @ Import directive on an ASP.NET page. The @ Import directive allows you to specify namespaces that are automatically imported into all pages of an application.
 
0
 
CCongdonCommented:
Ahhh, never mind, that's right. That only replaces @Import on an aspx page, not the code behind.
Yeah, you pretty much have to using Imports/using on each and every code behind page.
0
 
WiggingAuthor Commented:
lol
0
 
CCongdonCommented:
If you want to close/refund on this question, I won't object...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now