Using global function for all web forms

R

RA

Hi

Is it possible to have a global function that I can access from all the aspx
web forms? This function basically will reset the Cache object to delete all
the stored fields within it.


Thanks,
Ronen
 
C

Chris Bower

You could create your own class that inherits from the Page class and set
all of your aspx pages to Inherit from your custom Page class instead of
Page directly. From there you could create functions that any of your pages
can access. Another option is to create a Static/Shared method in a class
somewhere and just call that. Keep in mind if you do that you'll have to
pass the context of whatever you're working with.
 
S

Steve C. Orr [MVP, MCSD]

Create a class. Instantiate it where you need it. It's as simple as that.
If you create the methods as Shared (in VB.NET) or Static (in C#) then you
don't even have to instantiate the
class.

If you're using VB.NET you have another option: Create a code module.
 
D

David A. Beck

Steve:

In the designer do I just right click the solution explorer and add a class?
Will this become a class that I can access from all the code behind vb.net
code for all the forms and the global.asax.vb?

Dab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,265
Messages
2,571,071
Members
48,771
Latest member
ElysaD

Latest Threads

Top