Solved

Learning ASP.NET ... Where to Store Functions

Posted on 2011-02-22
2
234 Views
Last Modified: 2012-05-11
Hello,

I have developed a number of MS Access applications in the past, and am now learning ASP.NET (version 4) in order to develop web applications.

In MS Access, the VB code is stored in either the form / report which uses it exclusively (private subs / functions), or in a module (public subs / functions).

In ASP.NET, I know that each aspx file has a .vb file with code that belongs to that page. My question is in how to organize the "public" code that can be called from multiple pages ... where should these public subs/functions be stored?

Thanks in advance -
0
Comment
Question by:JMS1965
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
Comment Utility
If you just want a file full of public methods, rather than going the OO approach of actually wrapping them as objects, then you can just add a class file to your project and mark your methods as Public and Shared.

i.e.
Public Class SharedMethods
    Public Shared Function MyMethod() As String
       Return "Hello World"
    End Function
End Class

Open in new window

0
 
LVL 21

Assisted Solution

by:Alpesh Patel
Alpesh Patel earned 250 total points
Comment Utility
Create Class and store it in App_Code folder to access to anywhere in application.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now