First time at using shared code in App_Code directory

Discussion in 'ASP .Net' started by bissatch, Feb 15, 2007.

  1. bissatch

    bissatch Guest


    I have been using the following tutorials:

    It would appear that it is instructing me to simply to create an
    App_Code folder and place the CustomClass.vb file there. I have done
    so and using the exact same code from the tutorial but it tells me the
    class is undefined:

    Obviously Im a little too new to this but do I need to do something
    where the app knows that classes are contained there? Thanks

    bissatch, Feb 15, 2007
    1. Advertisements

  2. bissatch

    Teemu Keiski Guest

    Is the class (or classes in this case) in a namespace? If it is, you'd need
    to import than namespace on the using page.

    And you haven't specified any other code sub directories?
    Teemu Keiski, Feb 15, 2007
    1. Advertisements

  3. bissatch

    bissatch Guest

    Sorry, I was under the impression that you had folders that the
    application would recognise and there was no need to define it in
    every page. Is this not the case?

    Also, how do I know if it is in the namespace?
    Do I not only need to specify code sub-directories if I create other
    ones besides App_Code? How do I specify these?

    I only know what the tutorials have specified and maybe overlooked
    some part. If there is anything that could be outlined that I should
    check for please let me know.


    bissatch, Feb 16, 2007
  4. bissatch

    Teemu Keiski Guest

    Namespace would mean that your classes are wrapper in namespace statement

    Namespace MyNS

    Public Class myTemp

    End Class

    End Namespace

    If you are only using App_Code, then you don't need to configure anything.
    It would e needed if you'd create separate folders under App_Code (for
    example one for classes written in C# and one for classes in VB.NET)

    Teemu Keiski
    AspInsider, ASP.NET MVP
    Teemu Keiski, Feb 18, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.