About partial class

  • Thread starter Thread starter Lau Lei Cheong
  • Start date Start date
L

Lau Lei Cheong

A few quick questions:

Is there a limitation on how much partial class files we can have for a
single class? And can a ASP.NET page file inherit a class from multiple
code-behind files? if so, do I need to point out all the codefiles in the
page directive, or just one of them is enough?
 
Greg said:
You are asking this question leads me to wonder if you are dealing with a
design problem.

Perhaps you could give more detail on why you need many partial classes?

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung


Hello:

I do not have experience in using partial class in ASP.NET webpage.
However, I have used partial class in ASP.NET web service (*.asmx).

I will assume that the ASP.NET webpage has the same effect in ASP.NET
web service.

It is OK to use partial class in ASP.NET web service.

In my experience in ASP.NET web service, it is not necessary to point
out all the codefiles in the WebService directive.
In my experience, I have one "service.asmx" and two codebehind files
"service.asmx.cs" and "service2.cs". Just the "service.asmx.cs" is in
the WebService directive in "service.asmx". "service.asmx.cs" is the
original file which was created by VS2005 and it has the webservice
attributes.


I use partial class because I want to group the testing functions in one
partial class. The testing functions are for list all the row data in
every tables in database. I can simplely remove the whole partial class
file to remove all testing functions.


P.S. I use VS2005 with the Web application project addin.
 
Hi,


Lau Lei Cheong said:
A few quick questions:

Is there a limitation on how much partial class files we can have for a
single class?

Yes, AFAIK there is no limitation of how many files can contain a single
class, remember that the compiler just join all them together at compiler
time.
And can a ASP.NET page file inherit a class from multiple code-behind
files?

there is an error there, the asp.net page inherit from a class, not from a
codebehind file. as so it can inherit from only one class.


if so, do I need to point out all the codefiles in the
page directive, or just one of them is enough?
IIRC CodeBehind is deprecated in 2.0.
 

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

Back
Top