Class definition location??

G

Guest

Hi,

I have found a need to define a class for use in a page code-behind class
file. I have a well structured model which consists of business logic
components and data access components. The class I need to define will only
be needed for this particular page. I am unsure where to put this utility
class definition and was thinking the best place for it is within my
code-behind file, such that;

namespace MyAppUI
{
public partial class MyPage
{
private MyUtilityClass muc = new MyUtilityClass();
...
...

}


public class MyUtilityClass
{
...

}

}


I haven't been able to find anybody else talk about the right places for
class definitions. Is this method acceptable?

Many thanks in advance.
 
B

bruce barker

if it public it should be its own file in app_code. if its only used by
the page, define it private inside the page class.

-- bruce (sqlwork.com)
 
G

Guest

Mark said:
Hi,

I have found a need to define a class for use in a page code-behind class
file. I have a well structured model which consists of business logic
components and data access components. The class I need to define will only
be needed for this particular page. I am unsure where to put this utility
class definition and was thinking the best place for it is within my
code-behind file, such that;

namespace MyAppUI
{
public partial class MyPage
{
private MyUtilityClass muc = new MyUtilityClass();
...
...

}


public class MyUtilityClass
{
...

}

}


I haven't been able to find anybody else talk about the right places for
class definitions. Is this method acceptable?

Many thanks in advance.

If the class is only going to be used within that page, then the best
place would be within the class for the page. Make it private also.
 
G

Guest

Thanks.

Göran Andersson said:
If the class is only going to be used within that page, then the best
place would be within the class for the page. Make it private also.
 

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

Top