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

Re-using Code

Status
Not open for further replies.

EnemyGateIsDown

Technical User
Oct 3, 2002
235
GB
Hi guys,

I have some functions which are common to a number of forms within my project. So i created a new vb file with a class name and put them into it.

I then thought I could just in the other forms just by inheriting it, however when I do that it says that I can only have one inherit statement containing one class?

So how can I access my "common functions" from my various forms?

Any help is as alway greatly appreciated.

Cheers,

Chris
 
Its ok think i may have asked too soon.. Looks like i can inherit System.Web.UI.Page in my "global functions" class and then inherit that in my forms...

Chris
 
Yes, that's basically called Page Inheritance. Another way (if you are using version 2.0 of the framework) is to use master pages and create a new instance of you class on the master page. Each child page that uses this master page, will have access to the class.

This is also a much easier way of applying the same functionality of page inheritance.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Also, another approach would be to create a utility class for those common functions, and possibly declare the functions as Shared. The advantage is, you can use these functions in UserControls, MasterPages, and other classes, etc, not just in classes that inherit from Page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top