Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Learning ASP.NET ... Where to Store Functions

Posted on 2011-02-22
2
238 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
ID: 34952217
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
ID: 34952546
Create Class and store it in App_Code folder to access to anywhere in application.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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