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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

centralization of subs

Status
Not open for further replies.

gd082

Programmer
Mar 12, 2002
42
BE
I have 10 webform-pages. I have written some subs that i need on every page. For instance, to get data from my database i have a self-written function get_data(str) with a sql-instruction as a parameter and it returns a dataset which contains my requested data. Now i copy and paste this sub on every page.

Isn't it possible to place these subs in one file and add a reference to it from every webform page?

If so, how can i do this?

thnx in advance

 
If you don't want to create a dll to hold them, just create a module file within your project, put the subs in there, and declare them public. That way, any page in your project will be able to access them.

Putting them in classes in a dll is better 3 tiered architecture, but if you don't care about that stuff, the module idea will work just fine.

Jack
 
Thx a lot Jack.

But don't we need a reference in our webforms to the module file?

greetz

 
no, not if its local.

If you had it in a dll or something outside your project, then you'd need a reference.

If you declare it public within a module, it should be available from all your project files.

I just made one to test the theory, and it worked.

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top