Visual Studio 2005 (Beta 1) and auto-generated partial classes

C

C.Batt

Long, annoying story:

I'm having trouble viewing the auto-generated code of an aspx web form.

There doesn't seem to be a "show all" (or "reveal all" or anything like
that) button in the solution explorer window. All I can see in the
solution explorer, for a web site type of project, are the normal .aspx
and .aspx.cs files (as well as standard things like .html, etc...).

If I open an aspx.cs file, I can't "go to definition" of the partial
class.

I've tried short cicuiting this by creating a simple <asp:label>
control. When I go into the aspx.cs file, the control pop-ups up in
intellisense and I can use it normally. So I know that it's being
defined _somewhere_.

If I highlight the name of the control, right click, and choose "go to
definition" I get a wonderful pop-up telling me that the definition is
hidden! (Gee wiz Microsoft, thanks for providing the helmet, but
sometimes I need to take it off to scratch my head!)

I get a similar result if I open the object browser and search for,
say, Login_aspx. The results pane shows 2 occurences, one in the
aspx.cs
file and another in the aspx page. If I select the aspx.cs reference,
it takes me to the file; if I select the aspx reference, it gives me
that wonderful "it's hidden!" pop-up.

I figure this has got to be a setting somewhere, I just don't know what
it is and I'm having trouble finding it.

Help?

(Thanks in advance)
 
C

C.Batt

Kinda funny, but after I posted my rant/question I was playing around
with code in the aspx. I noticed that if I added a control, whether
through the designer or in the markup, the object was accessible
immediately in the code file. I just guessed that something was
defining the object "somewhere" automagically, for me.

This article seems to confirm that and thus cut through my confusion.
Cool feature, but very strange coming from many years of hand-coding
everything. Great amounts of frustration.

Informative article. Thanks.
 
C

clintonG

We have to take things for granted now. When they say...

"All of the information that would go into the designer class is implied in
the .aspx file."

.... we must tell ourselves "we are monkeys too stupid to know what is in our
best interest and do not need to see any source code"

I've downloaded but haven't installed VS2005 Beta 2 yet but I did not and do
not like the fact that partial classes also hide the signature for all
controls. When I want to know the accessor method and name of a control I
have to waste time moving back and forth from the editor to the designer to
look into the properties pane. TARFU.

I sent a request to MSDN Product Feedback [1] suggesting control signatures
be retained in the source of the partial class and could be emitted as
comments within a #region but I do not know if they decided to adopt this
common sense compromise or if we have to waste a lot of time moving back and
forth.

<%= Clinton

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

C.Batt

I'm not sure it's that bad, but I catch your drift. I would hope to
see Web forms and Windows forms behaved similarly in VS 2005. What I
mean is that it would be nice to have an explicitly generated
partial-class "root" (for lack of a better word) file like the one
generated for Windows forms.

Is this changed at all in Beta 2?

In the defence of the current model, I am quite impressed by how well
it does keep the markup and the code-behind in sync without
intervention. Adding a control to the markup and specifying properties
and events auto-magically and transparently (invisibly?) adds the
proper object instantiation and event delegation code to the project.
In some ways this is very cool, but at the same time it's also pretty
frightening, or at least was in my case, because it's not consistent
with the Win-forms model nor consistent with how it was done in the
past. I don't like to have things hidden from me, and I'm sure that
I'm not the only developer who thinks like this.

Options, MS. Lots and lots of options to customize the environment to
suit our tastes. Giving control to developers makes developers happy.
 
B

Brock Allen

In the defence of the current model, I am quite impressed by how well
it does keep the markup and the code-behind in sync without
intervention.

Well, it doesn't though. If you use drag and drop, then perhaps it seems
fine, but given how brutal drag and drop is on the HTML I never use it. I
only ever work in the HTML mode. And when you do that, the IDE doesn't synch
up the codebehind unless you switch to design view (which reformats the HTML).
Also ever try making the <body runat=server>? Or adding a <head runat=server>?
It doesn't do those either.

As I just said in another post in this thread, with VS.NET 2005 I won't be
using codebehind anymore.
 
B

Brock Allen

This article seems to confirm that and thus cut through my confusion.
Cool feature, but very strange coming from many years of hand-coding
everything. Great amounts of frustration.

Well, the hand-coding (by manual field declarations in the codebehind) caused
endless frustration because the inherently broken inheritance model for codebehind.
The declaration in the ASPX should be sufficient, and it is, given how ASP.NET
is using that markup to provide the control for you. It's now "hidden" in
ASP.NET 2.0 in so far as they're trying to fix the original problem from
v1.1.

I've commented on this elsewhere, but given how in VS.NET 2005 there's now
adequate tool support (mainly intellisense) for developing single ASPX files
(without codebehind) I won't be using codebehind anymore for my projects.
It's quite refreshing to work without codebehind.
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top