ASP.Net 2.0 and partial classes

G

Guest

Hi all,

I was playing around with ASP.Net 2.0 and recognized that in case you use
Code-Behind/Beside (how is it called in future?) the parser still creates TWO
classes one partial class under the global namespace which is called the same
way than your codebehind class and another class under ASP namespace which is
called the way you named your ASPX file (using underscores instead of dots).
It's not enough, it playces the files you created into it's temp folder. So
my is question is now, what is this for? I thought (read various articles
about the new features) that the partial class thing was invented to avoid
inheritance... Or am I wrong? Maybe I missunderstood something.

Could please someone enlight me?!

Thanks in advance
Patrick
 
B

Brock Allen

The partial class is generated by ASP.NET to declare all of the server side
controls that you've declared in your ASPX file. In v1.1 you had to manually
(or VS.NET had to) declare a field for every control you had on your page.
That is no longer nedded, as the ASP.NET compiler does this for you.
 
C

clintonG

Except even a neophyte like me knows the narrow minded morons that designed
partial classes apparently still require a developer to make many trips back
to the Designer where he or she must select a control and scroll, scroll,
scroll the boat gently down the stream just to review the control's
properites in the Properties Window each time the initial properties are
needed for reference.

What was the name of that control again? Back to the Designer to scroll,
scroll, scroll the boat.
What a serious waste of time. In this context the implementation is FUBAR

I tried submitting to MSDN Product Feedback long ago suggesting a #region in
the partial class using commented signatures for each control.
If you agree my suggestion is the right way to implement references for
control signatures please say so at MSDN Product Feedback [1] before they go
RTM.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://lab.msdn.microsoft.com/ProductFeedback/Default.aspx
 
C

clintonG

It would be even cooler if the IDE supported Ctrl-s(ignature) at the
insertion point which would return Intellisense with a list of signatures
for controls in the page.

<%= Clinton Gallagher




clintonG said:
Except even a neophyte like me knows the narrow minded morons that
designed partial classes apparently still require a developer to make many
trips back to the Designer where he or she must select a control and
scroll, scroll, scroll the boat gently down the stream just to review the
control's properites in the Properties Window each time the initial
properties are needed for reference.

What was the name of that control again? Back to the Designer to scroll,
scroll, scroll the boat.
What a serious waste of time. In this context the implementation is FUBAR

I tried submitting to MSDN Product Feedback long ago suggesting a #region
in the partial class using commented signatures for each control.
If you agree my suggestion is the right way to implement references for
control signatures please say so at MSDN Product Feedback [1] before they
go RTM.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://lab.msdn.microsoft.com/ProductFeedback/Default.aspx


Brock Allen said:
The partial class is generated by ASP.NET to declare all of the server
side controls that you've declared in your ASPX file. In v1.1 you had to
manually (or VS.NET had to) declare a field for every control you had on
your page. That is no longer nedded, as the ASP.NET compiler does this
for you.
 
B

Brock Allen

Why doesn't typing "this." work?




It would be even cooler if the IDE supported Ctrl-s(ignature) at the
insertion point which would return Intellisense with a list of
signatures for controls in the page.

<%= Clinton Gallagher

Except even a neophyte like me knows the narrow minded morons that
designed partial classes apparently still require a developer to make
many trips back to the Designer where he or she must select a control
and scroll, scroll, scroll the boat gently down the stream just to
review the control's properites in the Properties Window each time
the initial properties are needed for reference.

What was the name of that control again? Back to the Designer to
scroll,
scroll, scroll the boat.
What a serious waste of time. In this context the implementation is
FUBAR
I tried submitting to MSDN Product Feedback long ago suggesting a
#region
in the partial class using commented signatures for each control.
If you agree my suggestion is the right way to implement references
for
control signatures please say so at MSDN Product Feedback [1] before
they
go RTM.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
[1] http://lab.msdn.microsoft.com/ProductFeedback/Default.aspx

The partial class is generated by ASP.NET to declare all of the
server side controls that you've declared in your ASPX file. In v1.1
you had to manually (or VS.NET had to) declare a field for every
control you had on your page. That is no longer nedded, as the
ASP.NET compiler does this for you.


Hi all,

I was playing around with ASP.Net 2.0 and recognized that in case
you use Code-Behind/Beside (how is it called in future?) the parser
still creates TWO classes one partial class under the global
namespace which is called the same way than your codebehind class
and another class under ASP namespace which is called the way you
named your ASPX file (using underscores instead of dots). It's not
enough, it playces the files you created into it's temp folder. So
my is question is now, what is this for? I thought (read various
articles about the new features) that the partial class thing was
invented to avoid inheritance... Or am I wrong? Maybe I
missunderstood something.

Could please someone enlight me?!

Thanks in advance
Patrick
 
G

Guest

Hi Brock,

thanks for your reply.

So I guess I missunderstood the following lines:

"Coding Models in ASP.NET 2.0

ASP.NET 2.0 continues to offer both the code-inline and code-behind coding
models. In terms of the code-inline model, very little has changed except for
the way that Microsoft Visual Studio 2005 supports single-file development.
For more details on changes in Visual Studio 2005 and how it handles
code-inline, see this article.

ASP.NET 2.0 addresses both the inheritance and compilation concerns of the
code-behind model by modifying the nature of the code-behind file. In ASP.NET
2.0, the code-behind file is no longer a full implementation of the
System.Web.UI.Page class. Instead, the code-behind file is a new construct
called a partial class. The partial class contains all of the user-defined
code, but omits all of the plumbing and connectivity code that was
auto-generated by Visual Studio .NET in ASP.NET 1.x. When an ASPX page with a
new code-behind file is requested, the ASP.NET 2.0 runtime will actually
combine the ASPX page and the partial class into a single class, rather than
two separate classes. "

You find the complete article here:
http://msdn.microsoft.com/asp.net/b...pull=/library/en-us/dnvs05/html/internals.asp

Regards
Patrick
 
B

Brock Allen

ASP.NET 2.0 continues to offer both the code-inline and code-behind
coding models. In terms of the code-inline model, very little has
changed except for the way that Microsoft Visual Studio 2005 supports
single-file development. For more details on changes in Visual Studio
2005 and how it handles code-inline, see this article.

I just think this means for a single file ASPX page there's now proper intellisense
in VS.NET. In v1.1 you couold do all of your layout and code in a single
ASPX file, it's just that it was painful to do. Now VS.NET gives full intellisense,
which is a godsend.
ASP.NET 2.0 addresses both the inheritance and compilation concerns of
the code-behind model by modifying the nature of the code-behind file.
In ASP.NET 2.0, the code-behind file is no longer a full
implementation of the System.Web.UI.Page class. Instead, the
code-behind file is a new construct called a partial class. The
partial class contains all of the user-defined code, but omits all of
the plumbing and connectivity code that was auto-generated by Visual
Studio .NET in ASP.NET 1.x. When an ASPX page with a new code-behind
file is requested, the ASP.NET 2.0 runtime will actually combine the
ASPX page and the partial class into a single class, rather than two
separate classes. "

This is for codebehind. Any time you declare a control in your ASPX that
you want to use in your codebehind you need to have that variable declared.
The reason is because the codebehind is a base class to the ASPX file. So
it's necessary to declare the control in the base class so it can operate
(and compile, of course) on the control. This was a manual process v1.1 and
VS.NET helped somewhat in this. Now in v2.0 ASP.NET dynamically adds a partial
to the base class and all this partial has is the control declarations --
just like you'd had in v1.1.

So, at the end of the day, ASP.NET is really no different in its inheritance
model, but the mechanics of how you get those classes is slightly different.

FWIW, I personally dislike the inheritance model. It was essentially mandatory
in v1.1 given how VS.NET worked, but now that there's full intellisense support
in a single ASPX file in v2.0, I'll be doing all my pages that way. Goodbye
to codebehind :)
 
C

clintonG

Son of a gum I learn something new everyday. Thanks for helpimg me feel
stoopit ;-)

<%= Clinton Gallagher

Brock Allen said:
Why doesn't typing "this." work?




It would be even cooler if the IDE supported Ctrl-s(ignature) at the
insertion point which would return Intellisense with a list of
signatures for controls in the page.

<%= Clinton Gallagher

Except even a neophyte like me knows the narrow minded morons that
designed partial classes apparently still require a developer to make
many trips back to the Designer where he or she must select a control
and scroll, scroll, scroll the boat gently down the stream just to
review the control's properites in the Properties Window each time
the initial properties are needed for reference.

What was the name of that control again? Back to the Designer to
scroll,
scroll, scroll the boat.
What a serious waste of time. In this context the implementation is
FUBAR
I tried submitting to MSDN Product Feedback long ago suggesting a
#region
in the partial class using commented signatures for each control.
If you agree my suggestion is the right way to implement references
for
control signatures please say so at MSDN Product Feedback [1] before
they
go RTM.
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
[1] http://lab.msdn.microsoft.com/ProductFeedback/Default.aspx


The partial class is generated by ASP.NET to declare all of the
server side controls that you've declared in your ASPX file. In v1.1
you had to manually (or VS.NET had to) declare a field for every
control you had on your page. That is no longer nedded, as the
ASP.NET compiler does this for you.


Hi all,

I was playing around with ASP.Net 2.0 and recognized that in case
you use Code-Behind/Beside (how is it called in future?) the parser
still creates TWO classes one partial class under the global
namespace which is called the same way than your codebehind class
and another class under ASP namespace which is called the way you
named your ASPX file (using underscores instead of dots). It's not
enough, it playces the files you created into it's temp folder. So
my is question is now, what is this for? I thought (read various
articles about the new features) that the partial class thing was
invented to avoid inheritance... Or am I wrong? Maybe I
missunderstood something.

Could please someone enlight me?!

Thanks in advance
Patrick
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top