Calling a C# Class from ASPX file

hello, i am trying to call a C# class from an asp.net website. It is a user class which i use for multiple programs. I am not using visual studio, i am using notepad. I am doing this because i wish to learn how it all works.

Basically i want to know where to place the C# class (e.g. What file/location) Or if there is a way to reference the C# class at any location.

Any help is much appreciated

-M3mph15

Comments

  • : hello, i am trying to call a C# class from an asp.net website. It is
    : a user class which i use for multiple programs. I am not using
    : visual studio, i am using notepad. I am doing this because i wish to
    : learn how it all works.
    :
    : Basically i want to know where to place the C# class (e.g. What
    : file/location) Or if there is a way to reference the C# class at any
    : location.
    :
    : Any help is much appreciated
    :
    : -M3mph15

    First of all, I can assure you that call a C# class from the asp.net page is feasible. You just need to put the dll in your bin folder and reference the namespace by registering it in your header section of the asp.net pages where you want to call. Then in the actual asp.net page, you can just call the class as if you are calling a local C# class.



    Brad Wang
    .NET Freelancer from China
  • : hello, i am trying to call a C# class from an asp.net website. It is
    : a user class which i use for multiple programs. I am not using
    : visual studio, i am using notepad. I am doing this because i wish to
    : learn how it all works.
    :
    : Basically i want to know where to place the C# class (e.g. What
    : file/location) Or if there is a way to reference the C# class at any
    : location.
    :
    : Any help is much appreciated
    :
    : -

    hi M3mph15,
    It is good programming practise to use of common method in a class file and use that class file ASP.net code behind file. You can do this using two ways as follows.

    1)You can directly create Class file in the .Net application itself. And place that file in the [italic][u]App_Code [/u][/italic]folder directly. Then create object of the respected class in the any of the code behind file and access any of the method of the class using that object.

    2)You can create class file outside the .Net application itself. Than add reference to the .dll of that class file to .Net application. After that .Net application itself creates [italic][u]Bin[/u][/italic] folder and place .dll in the that folder. So create object of the respected class in the any of the code behind file and access any of the method of the class using that object.

    Hope this will help you.
    Thanks & Regards
    Dilipv


    Dilip Kumar Vishwakarma
    Programmer
    [link=http://www.intelcs.com/]SharePoint Consulting[/link]

    If this post
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories