Common Function?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a common function (private void createDocument()) that I use in many
pages within my asp.net app. This function is coded into all of these
pages. What advise would you have to have this function only once in the
app and called from all applicable pages? Does it need to be in a .cs file
in the app_code folder? How would this function be called from the various
pages? I'd certainly appreciate any feedback you may have. Thank you.
 
Thank you. What if the createDocument() function references object on the
page like textboxes, etc.? Will this be a concern?
 
Thanks sloan. In my case the createDocument() function may reference
hundreds of different objects (textboxes, listboxes,etc.). Is there a way
to simply inherit from the page so I do not have to pass them as params?
 
I have a common function (private void createDocument()) that I use in many
pages within my asp.net app.  This function is coded into all of these
pages.  What advise would you have to have this function only once in the
app and called from all applicable pages?  Does it need to be in a .cs file
in the app_code folder?  How would this function be called from the various
pages?  I'd certainly appreciate any feedback you may have.  Thank you..

Hi,

How is that method accesible from all teh pages if it's declared
private?

I would create a public static method (maybe in a static class) that
receive a reference to Page (that would be the calling page) you then
would have somethig like:

page_Load( .... ){
MyStaticClass.MyStaticMethod( this);
}
 
Thank you.  What if the createDocument() function references object on the
page like textboxes, etc.?  Will this be a concern?












- Show quoted text -

Hi,

Are those controls common in all pages?
If so, make your pages to either inherit from a common page or create
an interface that declare properties to let you access those controls.
 
Thanks sloan.  In my case the createDocument() function may reference
hundreds of different objects (textboxes, listboxes,etc.).  Is there a way
to simply inherit from the page so I do not have to pass them as params?








- Show quoted text -

Whooa, hundreds of controls is not that common, maybe you should
explain with more details what is your escenario
 
These controls are all common within each page. Which is prefered, inherit
from a common page or create
an interface that declare properties to let you access those controls?

message
Thank you. What if the createDocument() function references object on the
page like textboxes, etc.? Will this be a concern?












- Show quoted text -

Hi,

Are those controls common in all pages?
If so, make your pages to either inherit from a common page or create
an interface that declare properties to let you access those controls.
 
Back
Top