text: CodeGuru Forums
  >
  .NET Programming
  >
  ASP.NET
  > asp include files to asp.net
  PDA
  Click to See Complete Forum and Search -->
  :
  asp include files to asp.net
  jaklotz
  May 18th, 2006, 10:05 AM
  I'm trying to migrate an existing 3-tier application to asp.net 2.0 (with VB.net), and would like to know the best way to handle the existing include files. These include files mostly consist of just a handful of sub routines or functions per each include file. Do I just convert each of these into their own little class and put them in app_code (and put an imports statement on the page that wants to use that class's functions/subs)? ...or do I convert them to just plain Modules (declaring as Public Module instead of Public Class)? What is the most efficient way to do this?
  Thanks
  ...also, why doesn't VS 2005 allow you to select a Module when adding an item to your project, like VS 2003 did?
  HairyMonkeyMan
  May 18th, 2006, 11:13 AM
  Put the includes into classes.. (inside a namespace)
  i.e
  NameSpace YourNamespace
  Public Class CommonFunctions
  Public Function SomeFunction() as Boolean
  End Function
  End Class
  End Namespace
  ' In your aspx.vb page
  Include YourNameSpace.CommonFunctions
  somevariable = SomeFunction()
  hope this helps
  jaklotz
  May 18th, 2006, 12:35 PM
  That does help - so is this more efficient than just using a user control, and that's why you suggested it?
  And if I want to assign stuff to a Session variable, then I could just use:
  HttpContext.Current.Session("VarName") = somevalue
  Correct (it seems to work)?
  Also, do I put this in App_Code? ..or does it not matter what folder in my website project it goes into? ...also, why does it have to be in a namespace?
  Thanks!!
  HairyMonkeyMan
  May 18th, 2006, 06:31 PM
  Hi again
  so is this more efficient than just using a user control?
  Ya lost me there :confused: What kind of user control are you thinking of?
  And if I want to assign stuff to a Session variable...
  Yup correctamundo ;)
  do I put this in App_Code?
  I don't think so (although thats were I normally put it).
  why does it have to be in a namespace?
  Some wiseguy at microsoft thinks its a good way to organise your classes. You can have seperate files with different classes within the same namespace. In asp, you only have a few built in classes (response, server, request etc...). In asp.net you have gazillions within their namespaces.
  Good luck with it :wave:
  codeguru.com