Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

global functions like what we had in classic asp

Status
Not open for further replies.

ITking2009

Programmer
Aug 4, 2009
23
US
Hi,
Coming from classic asp i am not able to figure out whats the right way to do this so any guideance is appreciated.

What i want to achieve is, like in classic asp we used to create functions in global.asa; for functions which would be called by various pages, Is that somethign what is recommended for ASP.NET? (creating functions in global.asax)?

Some people talk about using appcode and creating a class, is that somethign which is recommended? Don't i need to instantiate the class even if i want to use just one function from the class if i go that route?

Thanks.
 
asp.net is a framework to handle request/response for http. it's built on top of the .net framework. the .net framework is a compiled OOP language. similar to java.

the idea of OOP is you have instances objects, objects have behavior and data. typically a group of objects will work together to complete a specific workflow.

in your case you would create a new class (app_code directory works). create the public members for this class and add the logic to it.

then you would instantiate the object within your Page (code behind) and use the public members as necessary.

the global.asax is a webforms subclass of HttpApplication.

I would recommend you research:
1. the http request/response model of the web. in it's simplest form, it just text(bytes).
2. the asp.net framework and how it applies to the request/response model. simplified: asp.net is a pipeline for processing the http request and sending an http response. there are a variety of extension points and event hooks to add your own logic to the pipeline. most of the time you are dealing with collections of string/string key/value pairs (session, cache, appliation, items, params, cookies, form, query string, etc).
3. the webforms html engine (assuming that's what you are using) to understand how it works. webforms was designed to move desktop developers into the web environment. You will find concepts like: viewstate, postback, control events within webforms. webforms creates the illusion of state for a stateless environment. you will not find these concepts in any other html engine in any language. webforms is built on top of asp.net. webforms is not asp.net.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top