473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How do I tell VS2005 about a code-behind file?

Hello,

I have been developing ASP.NET with a text editor so far (better way to
learn initially), and have now been trying Visual Web Developer. I want
to create a project for an existing site and add the files to it. I can
add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
file si the code-behind for any particular .aspx file.

When you create a new aspx page in VWD, it automatically puts the
code-behind file with the aspx. Can I make it do this for my existing
files?

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #1
19 3720
: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
: file si the code-behind for any particular .aspx file.

Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
top.
--
Cheers,
Gaurav Vaish
http://mastergaurav.org
-----------------------------
Nov 19 '05 #2
>: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
: file si the code-behind for any particular .aspx file.

Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
top.


VWD complained at CodeBehind, saying it was no longer supported. I tried
using CodeFile instead as the ones VWD generates use that, and then it
recognised the .cs file as being the code-behind for the .aspx, but
didn't change the display in the solution explorer. They were still
shown as separate items.

Any other ideas? Thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #3
re:
it recognised the .cs file as being the code-behind for the .aspx, but didn't change the
display in the solution explorer. They were still shown as separate items.


I don't understand. They will *always* be shown as separate items.

You can edit *.aspx and *.aspx.cs files separately.
Am I missing something ?


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mw**************@nospamthankyou.spam...
: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
: file si the code-behind for any particular .aspx file.

Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
top.


VWD complained at CodeBehind, saying it was no longer supported. I tried using CodeFile
instead as the ones VWD generates use that, and then it recognised the .cs file as being
the code-behind for the .aspx, but didn't change the display in the solution explorer.
They were still shown as separate items.

Any other ideas? Thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #4
>> it recognised the .cs file as being the code-behind for the .aspx,
but didn't change the
display in the solution explorer. They were still shown as separate items.
I don't understand. They will *always* be shown as separate items.

You can edit *.aspx and *.aspx.cs files separately.
Am I missing something ?


Maybe I didn't explain it clearly enough. In the solution explorer, you
see an entry for the .aspx file, with a small + sign to the left of the
icon. If you click the + sign, a node opens below it for the .cs file.

When I add pre-existing files, they just show as two separate top-level
nodes in the solution explorer. I'm trying to find a way of persuading
VWD to put the .cs file as a node below the .aspx file, so the top-level
nodes are (mostly) .aspx files.

Does that explain it any better?
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mw**************@nospamthankyou.spam...
>: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
: file si the code-behind for any particular .aspx file.

Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
top.


VWD complained at CodeBehind, saying it was no longer supported. I
tried using CodeFile
instead as the ones VWD generates use that, and then it recognised
the .cs file as being
the code-behind for the .aspx, but didn't change the display in the
solution explorer.
They were still shown as separate items.

Any other ideas? Thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #5
re:
Maybe I didn't explain it clearly enough.


I understand better now.

To get the IDE to understand that the files are related,
just select *both* the *.aspx and the *aspx.cs file
at the same time, and add them simultaneously.

The IDE will display them as you want them to display.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:0n**************@nospamthankyou.spam...
it recognised the .cs file as being the code-behind for the .aspx, but didn't change
the
display in the solution explorer. They were still shown as separate items.


I don't understand. They will *always* be shown as separate items.

You can edit *.aspx and *.aspx.cs files separately.
Am I missing something ?


Maybe I didn't explain it clearly enough. In the solution explorer, you see an entry for
the .aspx file, with a small + sign to the left of the icon. If you click the + sign, a
node opens below it for the .cs file.

When I add pre-existing files, they just show as two separate top-level nodes in the
solution explorer. I'm trying to find a way of persuading VWD to put the .cs file as a
node below the .aspx file, so the top-level nodes are (mostly) .aspx files.

Does that explain it any better?
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mw**************@nospamthankyou.spam...
>: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
: file si the code-behind for any particular .aspx file.

Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
top.

VWD complained at CodeBehind, saying it was no longer supported. I tried using
CodeFile
instead as the ones VWD generates use that, and then it recognised the .cs file as
being
the code-behind for the .aspx, but didn't change the display in the solution explorer.
They were still shown as separate items.

Any other ideas? Thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #6
Juan,

Thanks for the tip, but it didn't work. I tried adding the two files
simultaneously as they are (ie with the code-behind file specified using
the Src attribute of the page directive) and it didn't work.

I then deleted them from the project, changed the .aspx file to use
CodeFile (using Notepad) and adding them again, but this didn't work
either. I also tried using COdeBehind, but that didn't work.

Any other ideas? Thanks for the reply.
re:
Maybe I didn't explain it clearly enough.


I understand better now.

To get the IDE to understand that the files are related,
just select *both* the *.aspx and the *aspx.cs file
at the same time, and add them simultaneously.

The IDE will display them as you want them to display.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:0n**************@nospamthankyou.spam...
it recognised the .cs file as being the code-behind for the .aspx,
but didn't change
the
display in the solution explorer. They were still shown as separate items.

I don't understand. They will *always* be shown as separate items.

You can edit *.aspx and *.aspx.cs files separately.
Am I missing something ?


Maybe I didn't explain it clearly enough. In the solution explorer,
you see an entry for
the .aspx file, with a small + sign to the left of the icon. If you
click the + sign, a
node opens below it for the .cs file.

When I add pre-existing files, they just show as two separate
top-level nodes in the
solution explorer. I'm trying to find a way of persuading VWD to put
the .cs file as a
node below the .aspx file, so the top-level nodes are (mostly) .aspx files.

Does that explain it any better?
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mw**************@nospamthankyou.spam...
>: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
>: file si the code-behind for any particular .aspx file.
>
> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>Directive on the
>top.

VWD complained at CodeBehind, saying it was no longer supported. I
tried using
CodeFile
instead as the ones VWD generates use that, and then it recognised
the .cs file as
being
the code-behind for the .aspx, but didn't change the display in the
solution explorer.
They were still shown as separate items.

Any other ideas? Thanks.

--
Alan Silver
(anything added below this line is nothing to do with me)


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #7
re:
Thanks for the tip, but it didn't work. I tried adding the two files
It works fine for me.

Let's review the mechanics and make sure you're doing what you should.

1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam... Juan,

Thanks for the tip, but it didn't work. I tried adding the two files simultaneously as
they are (ie with the code-behind file specified using the Src attribute of the page
directive) and it didn't work.

I then deleted them from the project, changed the .aspx file to use CodeFile (using
Notepad) and adding them again, but this didn't work either. I also tried using
COdeBehind, but that didn't work.

Any other ideas? Thanks for the reply.
re:
Maybe I didn't explain it clearly enough.


I understand better now.

To get the IDE to understand that the files are related,
just select *both* the *.aspx and the *aspx.cs file
at the same time, and add them simultaneously.

The IDE will display them as you want them to display.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:0n**************@nospamthankyou.spam...
> it recognised the .cs file as being the code-behind for the .aspx, but didn't change
> the
> display in the solution explorer. They were still shown as separate items.

I don't understand. They will *always* be shown as separate items.

You can edit *.aspx and *.aspx.cs files separately.
Am I missing something ?

Maybe I didn't explain it clearly enough. In the solution explorer, you see an entry
for
the .aspx file, with a small + sign to the left of the icon. If you click the + sign,
a
node opens below it for the .cs file.

When I add pre-existing files, they just show as two separate top-level nodes in the
solution explorer. I'm trying to find a way of persuading VWD to put the .cs file as a
node below the .aspx file, so the top-level nodes are (mostly) .aspx files.

Does that explain it any better?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:mw**************@nospamthankyou.spam...
> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs
>>: file si the code-behind for any particular .aspx file.
>>
>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page" Directive on the
>>top.
>
> VWD complained at CodeBehind, saying it was no longer supported. I tried using
> CodeFile
> instead as the ones VWD generates use that, and then it recognised the .cs file as
> being
> the code-behind for the .aspx, but didn't change the display in the solution
> explorer.
> They were still shown as separate items.
>
> Any other ideas? Thanks.
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #8
>re:
Thanks for the tip, but it didn't work. I tried adding the two files
It works fine for me.

Let's review the mechanics and make sure you're doing what you should.


I did exactly what you said, except that I was adding them to an
existing web site instead of starting a new project, but that shouldn't
be relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it
didn't help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra
1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam...
Juan,

Thanks for the tip, but it didn't work. I tried adding the two files
simultaneously as
they are (ie with the code-behind file specified using the Src
attribute of the page
directive) and it didn't work.

I then deleted them from the project, changed the .aspx file to use
CodeFile (using
Notepad) and adding them again, but this didn't work either. I also
tried using
COdeBehind, but that didn't work.

Any other ideas? Thanks for the reply.
re:
Maybe I didn't explain it clearly enough.

I understand better now.

To get the IDE to understand that the files are related,
just select *both* the *.aspx and the *aspx.cs file
at the same time, and add them simultaneously.

The IDE will display them as you want them to display.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:0n**************@nospamthankyou.spam...
>> it recognised the .cs file as being the code-behind for the
>>.aspx, but didn't change
>> the
>> display in the solution explorer. They were still shown as
>>separate items.
>
>I don't understand. They will *always* be shown as separate items.
>
>You can edit *.aspx and *.aspx.cs files separately.
>Am I missing something ?

Maybe I didn't explain it clearly enough. In the solution explorer,
you see an entry
for
the .aspx file, with a small + sign to the left of the icon. If you
click the + sign,
a
node opens below it for the .cs file.

When I add pre-existing files, they just show as two separate
top-level nodes in the
solution explorer. I'm trying to find a way of persuading VWD to
put the .cs file as a
node below the .aspx file, so the top-level nodes are (mostly) .aspx files.

Does that explain it any better?

>Juan T. Llibre, ASP.NET MVP
>ASP.NET FAQ : http://asp.net.do/faq/
>Foros de ASP.NET en Español : http://asp.net.do/foros/
>======================================
>"Alan Silver" <al*********@nospam.thanx> wrote in message
>news:mw**************@nospamthankyou.spam.. .
>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>> >:which .cs
>>>: file si the code-behind for any particular .aspx file.
>>>
>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>Directive on the
>>>top.
>>
>> VWD complained at CodeBehind, saying it was no longer supported.
>>I tried using
>> CodeFile
>> instead as the ones VWD generates use that, and then it
>>recognised the .cs file as
>> being
>> the code-behind for the .aspx, but didn't change the display in
>>solution
>> explorer.
>> They were still shown as separate items.
>>
>> Any other ideas? Thanks.
>>
>> --
>> Alan Silver
>> (anything added below this line is nothing to do with me)
>
>

--
Alan Silver
(anything added below this line is nothing to do with me)


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #9
What's the name of your page? If, for example, it's ProductList.aspx, your
code-behind file should be called ProductList.aspx.cs I think.

Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:E2**************@nospamthankyou.spam...
re:
Thanks for the tip, but it didn't work. I tried adding the two files


It works fine for me.

Let's review the mechanics and make sure you're doing what you should.


I did exactly what you said, except that I was adding them to an existing
web site instead of starting a new project, but that shouldn't be
relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it didn't
help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra
1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the
aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam...
Juan,

Thanks for the tip, but it didn't work. I tried adding the two files
simultaneously as
they are (ie with the code-behind file specified using the Src attribute
of the page
directive) and it didn't work.

I then deleted them from the project, changed the .aspx file to use
CodeFile (using
Notepad) and adding them again, but this didn't work either. I also
tried using
COdeBehind, but that didn't work.

Any other ideas? Thanks for the reply.

re:
> Maybe I didn't explain it clearly enough.

I understand better now.

To get the IDE to understand that the files are related,
just select *both* the *.aspx and the *aspx.cs file
at the same time, and add them simultaneously.

The IDE will display them as you want them to display.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:0n**************@nospamthankyou.spam...
>>> it recognised the .cs file as being the code-behind for the .aspx,
>>> but didn't change
>>> the
>>> display in the solution explorer. They were still shown as separate
>>> items.
>>
>>I don't understand. They will *always* be shown as separate items.
>>
>>You can edit *.aspx and *.aspx.cs files separately.
>>Am I missing something ?
>
> Maybe I didn't explain it clearly enough. In the solution explorer,
> you see an entry
> for
> the .aspx file, with a small + sign to the left of the icon. If you
> click the + sign,
> a
> node opens below it for the .cs file.
>
> When I add pre-existing files, they just show as two separate
> top-level nodes in the
> solution explorer. I'm trying to find a way of persuading VWD to put
> the .cs file as a
> node below the .aspx file, so the top-level nodes are (mostly) .aspx
> files.
>
> Does that explain it any better?
>
>>Juan T. Llibre, ASP.NET MVP
>>ASP.NET FAQ : http://asp.net.do/faq/
>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>======================================
>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>news:mw**************@nospamthankyou.spam. ..
>>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>>> >:which .cs
>>>>: file si the code-behind for any particular .aspx file.
>>>>
>>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>> Directive on the
>>>>top.
>>>
>>> VWD complained at CodeBehind, saying it was no longer supported. I
>>> tried using
>>> CodeFile
>>> instead as the ones VWD generates use that, and then it recognised
>>> the .cs file as
>>> being
>>> the code-behind for the .aspx, but didn't change the display in
>>> solution
>>> explorer.
>>> They were still shown as separate items.
>>>
>>> Any other ideas? Thanks.
>>>
>>> --
>>> Alan Silver
>>> (anything added below this line is nothing to do with me)
>>
>>
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #10
Alan Silver wrote:
re:
Thanks for the tip, but it didn't work. I tried adding the two files


It works fine for me.

Let's review the mechanics and make sure you're doing what you should.


I did exactly what you said, except that I was adding them to an
existing web site instead of starting a new project, but that shouldn't
be relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it
didn't help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra

In Visual Studio 2003 you can sometimes get this problem. May or may
not work the same in 2005, or there may be something similar, but after
adding all the files to the project, close down Visual Studio, then
open the project file in Notepad.

It'll have a whole load of:
<File
RelPath = "<Name of CS File>"
SubType = "Code"
BuildAction = "Compile"
/>

You want to change these to resemble:
<File
RelPath = "<Name of CS File>"
DependentUpon = "<Name of Aspx file>"
SubType = "ASPXCodeBehind"
BuildAction = "Compile"
/>

Easiest way to get format correct is to add a new page as you
described, then open the project file in notepad and find how the two
files have been added.

Damien

Nov 19 '05 #11
>What's the name of your page? If, for example, it's ProductList.aspx, your
code-behind file should be called ProductList.aspx.cs I think.
Ooh, I wonder if that's the reason then? I adopted the convention of
ferret.aspx and ferret.cs for the two pages. I didn't like the .aspx.cs
idea (don't know why), and given that it seemed to be simply one way of
doing it, I picked my own.

<pause for experiment>

Well cut off both my legs and call me Shorty!! It worked. OK, so now I
know how to do it, I'll have to go and change the name of all my pages.
What a pain. I wonder why they insisted on that naming convention. It
seems very restrictive. Why can't I name my files anything I like?

Thanks for the reply.
Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:E2**************@nospamthankyou.spam...
>re:
Thanks for the tip, but it didn't work. I tried adding the two files

It works fine for me.

Let's review the mechanics and make sure you're doing what you should.


I did exactly what you said, except that I was adding them to an existing
web site instead of starting a new project, but that shouldn't be
relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it didn't
help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra
1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the
aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam...
Juan,

Thanks for the tip, but it didn't work. I tried adding the two files
simultaneously as
they are (ie with the code-behind file specified using the Src attribute
of the page
directive) and it didn't work.

I then deleted them from the project, changed the .aspx file to use
CodeFile (using
Notepad) and adding them again, but this didn't work either. I also
tried using
COdeBehind, but that didn't work.

Any other ideas? Thanks for the reply.

>re:
>> Maybe I didn't explain it clearly enough.
>
>I understand better now.
>
>To get the IDE to understand that the files are related,
>just select *both* the *.aspx and the *aspx.cs file
>at the same time, and add them simultaneously.
>
>The IDE will display them as you want them to display.
>
>
>
>Juan T. Llibre, ASP.NET MVP
>ASP.NET FAQ : http://asp.net.do/faq/
>Foros de ASP.NET en Español : http://asp.net.do/foros/
>======================================
>"Alan Silver" <al*********@nospam.thanx> wrote in message
>news:0n**************@nospamthankyou.spam.. .
>>>> it recognised the .cs file as being the code-behind for the .aspx,
>>>> but didn't change
>>>> the
>>>> display in the solution explorer. They were still shown as separate
>>>> items.
>>>
>>>I don't understand. They will *always* be shown as separate items.
>>>
>>>You can edit *.aspx and *.aspx.cs files separately.
>>>Am I missing something ?
>>
>> Maybe I didn't explain it clearly enough. In the solution explorer,
>> you see an entry
>> for
>> the .aspx file, with a small + sign to the left of the icon. If you
>> click the + sign,
>> a
>> node opens below it for the .cs file.
>>
>> When I add pre-existing files, they just show as two separate
>> top-level nodes in the
>> solution explorer. I'm trying to find a way of persuading VWD to put
>> the .cs file as a
>> node below the .aspx file, so the top-level nodes are (mostly) .aspx
>> files.
>>
>> Does that explain it any better?
>>
>>>Juan T. Llibre, ASP.NET MVP
>>>ASP.NET FAQ : http://asp.net.do/faq/
>>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>>======================================
>>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>>news:mw**************@nospamthankyou.spam.. .
>>>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>>>> >:which .cs
>>>>>: file si the code-behind for any particular .aspx file.
>>>>>
>>>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>>> Directive on the
>>>>>top.
>>>>
>>>> VWD complained at CodeBehind, saying it was no longer supported. I
>>>> tried using
>>>> CodeFile
>>>> instead as the ones VWD generates use that, and then it recognised
>>>> the .cs file as
>>>> being
>>>> the code-behind for the .aspx, but didn't change the display in
>>>> solution
>>>> explorer.
>>>> They were still shown as separate items.
>>>>
>>>> Any other ideas? Thanks.
>>>>
>>>> --
>>>> Alan Silver
>>>> (anything added below this line is nothing to do with me)
>>>
>>>
>>
>> --
>> Alan Silver
>> (anything added below this line is nothing to do with me)
>
>

--
Alan Silver
(anything added below this line is nothing to do with me)


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #12
>In Visual Studio 2003 you can sometimes get this problem. May or may
not work the same in 2005, or there may be something similar, but after
adding all the files to the project, close down Visual Studio, then open
the project file in Notepad.

It'll have a whole load of:
<File
RelPath = "<Name of CS File>"
SubType = "Code"
BuildAction = "Compile"
/>

You want to change these to resemble:
<File
RelPath = "<Name of CS File>"
DependentUpon = "<Name of Aspx file>"
SubType = "ASPXCodeBehind"
BuildAction = "Compile"
/>

Easiest way to get format correct is to add a new page as you described,
then open the project file in notepad and find how the two files have
been added.


Damien,

Thanks for the reply, but I can't see this info anywhere. There is a
..sln file, but that doesn't contain anything like you suggested. The
only other project file I can see is a .suo file, which is binary.

Which file should I open? For interest, the .sln file contains...
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Web Developer Express 2005
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "C:\...\FirstTest\", "..\..\..\WebSites\FirstTest\", "{765AD130-A4CC-
4A92-BBD7-674C4E832F2E}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.VirtualPath = "/FirstTest"
Debug.AspNetCompiler.PhysicalPath = "..\..\..\WebSites\FirstTest\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\FirstTest\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "true"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/FirstTest"
Release.AspNetCompiler.PhysicalPath = "..\..\..\WebSites\FirstTest\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\FirstTest\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "true"
Release.AspNetCompiler.Debug = "False"
VWDPort = "1031"
DefaultWebSiteLanguage = "Visual C#"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{765AD130-A4CC-4A92-BBD7-674C4E832F2E}.Debug|.NET.ActiveCfg = Debug|.NET
{765AD130-A4CC-4A92-BBD7-674C4E832F2E}.Debug|.NET.Build.0 = Debug|.NET
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #13
re:
Ooh, I wonder if that's the reason then? I adopted the convention of ferret.aspx and
ferret.cs for the two pages. I didn't like the .aspx.cs idea (don't know why), and given
that it seemed to be simply one way of doing it, I picked my own.


The road to hell is paved with good conventions, err, intentions... ;-)


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:XM**************@nospamthankyou.spam...
What's the name of your page? If, for example, it's ProductList.aspx, your
code-behind file should be called ProductList.aspx.cs I think.


Ooh, I wonder if that's the reason then? I adopted the convention of ferret.aspx and
ferret.cs for the two pages. I didn't like the .aspx.cs idea (don't know why), and given
that it seemed to be simply one way of doing it, I picked my own.

<pause for experiment>

Well cut off both my legs and call me Shorty!! It worked. OK, so now I know how to do
it, I'll have to go and change the name of all my pages. What a pain. I wonder why they
insisted on that naming convention. It seems very restrictive. Why can't I name my files
anything I like?

Thanks for the reply.
Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:E2**************@nospamthankyou.spam...
>re:
> Thanks for the tip, but it didn't work. I tried adding the two files

It works fine for me.

Let's review the mechanics and make sure you're doing what you should.

I did exactly what you said, except that I was adding them to an existing
web site instead of starting a new project, but that shouldn't be
relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it didn't
help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra

1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the
aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam...
> Juan,
>
> Thanks for the tip, but it didn't work. I tried adding the two files
> simultaneously as
> they are (ie with the code-behind file specified using the Src attribute
> of the page
> directive) and it didn't work.
>
> I then deleted them from the project, changed the .aspx file to use
> CodeFile (using
> Notepad) and adding them again, but this didn't work either. I also
> tried using
> COdeBehind, but that didn't work.
>
> Any other ideas? Thanks for the reply.
>
>>re:
>>> Maybe I didn't explain it clearly enough.
>>
>>I understand better now.
>>
>>To get the IDE to understand that the files are related,
>>just select *both* the *.aspx and the *aspx.cs file
>>at the same time, and add them simultaneously.
>>
>>The IDE will display them as you want them to display.
>>
>>
>>
>>Juan T. Llibre, ASP.NET MVP
>>ASP.NET FAQ : http://asp.net.do/faq/
>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>======================================
>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>news:0n**************@nospamthankyou.spam. ..
>>>>> it recognised the .cs file as being the code-behind for the .aspx,
>>>>> but didn't change
>>>>> the
>>>>> display in the solution explorer. They were still shown as separate
>>>>> items.
>>>>
>>>>I don't understand. They will *always* be shown as separate items.
>>>>
>>>>You can edit *.aspx and *.aspx.cs files separately.
>>>>Am I missing something ?
>>>
>>> Maybe I didn't explain it clearly enough. In the solution explorer,
>>> you see an entry
>>> for
>>> the .aspx file, with a small + sign to the left of the icon. If you
>>> click the + sign,
>>> a
>>> node opens below it for the .cs file.
>>>
>>> When I add pre-existing files, they just show as two separate
>>> top-level nodes in the
>>> solution explorer. I'm trying to find a way of persuading VWD to put
>>> the .cs file as a
>>> node below the .aspx file, so the top-level nodes are (mostly) .aspx
>>> files.
>>>
>>> Does that explain it any better?
>>>
>>>>Juan T. Llibre, ASP.NET MVP
>>>>ASP.NET FAQ : http://asp.net.do/faq/
>>>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>>>======================================
>>>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>>>news:mw**************@nospamthankyou.spam. ..
>>>>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>>>>> >:which .cs
>>>>>>: file si the code-behind for any particular .aspx file.
>>>>>>
>>>>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>>>> Directive on the
>>>>>>top.
>>>>>
>>>>> VWD complained at CodeBehind, saying it was no longer supported. I
>>>>> tried using
>>>>> CodeFile
>>>>> instead as the ones VWD generates use that, and then it recognised
>>>>> the .cs file as
>>>>> being
>>>>> the code-behind for the .aspx, but didn't change the display in
>>>>> solution
>>>>> explorer.
>>>>> They were still shown as separate items.
>>>>>
>>>>> Any other ideas? Thanks.
>>>>>
>>>>> --
>>>>> Alan Silver
>>>>> (anything added below this line is nothing to do with me)
>>>>
>>>>
>>>
>>> --
>>> Alan Silver
>>> (anything added below this line is nothing to do with me)
>>
>>
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #14
Glad you got it to work.

The naming convention does make sense from a graphical viewpoint - you might
have a page called ferret.aspx, with the code behind called ferret.aspx.cs -
it's the code for the ferret.aspx page, so it follows it would be "below" it
in a tree structure [constructed from multiple extensions]. You might also
have a ferret class, which would make sense to save as ferret.cs. With your
naming, your ferret class would have to be saved as something like
ferret.class.cs.
Admittedly, you might be the type of coder that likes to combine all objects
into one, for example, objects.cs file, but many coders, myself included,
tend to keep to one class per file, treating them as separate units.

As a side note, one could argue that given the aspx naming convention, the
Winforms naming is wrong, or vice-versa (frmMain.cs, frmMain.Designer.cs and
frmMain.resx, rather than frmMain.frm, frmMain.frm.cs and frmMain.frm.resx)
but they're developed by different teams and haven't been similarised -
can't think of the correct term :)

Hope that makes sense... :)

Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:XM**************@nospamthankyou.spam...
What's the name of your page? If, for example, it's ProductList.aspx,
your
code-behind file should be called ProductList.aspx.cs I think.


Ooh, I wonder if that's the reason then? I adopted the convention of
ferret.aspx and ferret.cs for the two pages. I didn't like the .aspx.cs
idea (don't know why), and given that it seemed to be simply one way of
doing it, I picked my own.

<pause for experiment>

Well cut off both my legs and call me Shorty!! It worked. OK, so now I
know how to do it, I'll have to go and change the name of all my pages.
What a pain. I wonder why they insisted on that naming convention. It
seems very restrictive. Why can't I name my files anything I like?

Thanks for the reply.
Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:E2**************@nospamthankyou.spam...
>re:
> Thanks for the tip, but it didn't work. I tried adding the two files

It works fine for me.

Let's review the mechanics and make sure you're doing what you should.

I did exactly what you said, except that I was adding them to an
existing
web site instead of starting a new project, but that shouldn't be
relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it
didn't
help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra

1. Click "Website" on the VS.NET 2005 menu for VWD.
2. Click "Add Existing Item".
3. Navigate to the folder where the files exist.
4. Select your aspx file ( click on it *once* to highlight it ).
5. Hold the Control key and select the .cs file which corresponds to the
aspx.
6. Now you have *both* files highlighted
7. Click the "Add" button.

Is that what you're doing ?

When I do that, the aspx file is added to my Solution Explorer,
with the corresponding codebehind .cs file linked to it.

I can see the linked codebehind .cs file by clicking the plus sign (+)
in front of the aspx file.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:UA**************@nospamthankyou.spam...
> Juan,
>
> Thanks for the tip, but it didn't work. I tried adding the two files
> simultaneously as
> they are (ie with the code-behind file specified using the Src
> attribute
> of the page
> directive) and it didn't work.
>
> I then deleted them from the project, changed the .aspx file to use
> CodeFile (using
> Notepad) and adding them again, but this didn't work either. I also
> tried using
> COdeBehind, but that didn't work.
>
> Any other ideas? Thanks for the reply.
>
>>re:
>>> Maybe I didn't explain it clearly enough.
>>
>>I understand better now.
>>
>>To get the IDE to understand that the files are related,
>>just select *both* the *.aspx and the *aspx.cs file
>>at the same time, and add them simultaneously.
>>
>>The IDE will display them as you want them to display.
>>
>>
>>
>>Juan T. Llibre, ASP.NET MVP
>>ASP.NET FAQ : http://asp.net.do/faq/
>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>======================================
>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>news:0n**************@nospamthankyou.spam. ..
>>>>> it recognised the .cs file as being the code-behind for the .aspx,
>>>>> but didn't change
>>>>> the
>>>>> display in the solution explorer. They were still shown as
>>>>> separate
>>>>> items.
>>>>
>>>>I don't understand. They will *always* be shown as separate items.
>>>>
>>>>You can edit *.aspx and *.aspx.cs files separately.
>>>>Am I missing something ?
>>>
>>> Maybe I didn't explain it clearly enough. In the solution explorer,
>>> you see an entry
>>> for
>>> the .aspx file, with a small + sign to the left of the icon. If you
>>> click the + sign,
>>> a
>>> node opens below it for the .cs file.
>>>
>>> When I add pre-existing files, they just show as two separate
>>> top-level nodes in the
>>> solution explorer. I'm trying to find a way of persuading VWD to put
>>> the .cs file as a
>>> node below the .aspx file, so the top-level nodes are (mostly) .aspx
>>> files.
>>>
>>> Does that explain it any better?
>>>
>>>>Juan T. Llibre, ASP.NET MVP
>>>>ASP.NET FAQ : http://asp.net.do/faq/
>>>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>>>======================================
>>>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>>>news:mw**************@nospamthankyou.spam. ..
>>>>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>>>>> >:which .cs
>>>>>>: file si the code-behind for any particular .aspx file.
>>>>>>
>>>>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>>>> Directive on the
>>>>>>top.
>>>>>
>>>>> VWD complained at CodeBehind, saying it was no longer supported. I
>>>>> tried using
>>>>> CodeFile
>>>>> instead as the ones VWD generates use that, and then it recognised
>>>>> the .cs file as
>>>>> being
>>>>> the code-behind for the .aspx, but didn't change the display in
>>>>> solution
>>>>> explorer.
>>>>> They were still shown as separate items.
>>>>>
>>>>> Any other ideas? Thanks.
>>>>>
>>>>> --
>>>>> Alan Silver
>>>>> (anything added below this line is nothing to do with me)
>>>>
>>>>
>>>
>>> --
>>> Alan Silver
>>> (anything added below this line is nothing to do with me)
>>
>>
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #15
>The road to hell is paved with good conventions, err, intentions... ;-)

<g>

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #16
Jevon,

Yup, it makes lots of sense. I guess this is one of those irritating
things that you get when learning something new, especially when you
start off doing it by hand (all text editor so far, this is my first
dabble with VWD).

Still, all part of the learning experience.

Ta ra
Glad you got it to work.

The naming convention does make sense from a graphical viewpoint - you might
have a page called ferret.aspx, with the code behind called ferret.aspx.cs -
it's the code for the ferret.aspx page, so it follows it would be "below" it
in a tree structure [constructed from multiple extensions]. You might also
have a ferret class, which would make sense to save as ferret.cs. With your
naming, your ferret class would have to be saved as something like
ferret.class.cs.
Admittedly, you might be the type of coder that likes to combine all objects
into one, for example, objects.cs file, but many coders, myself included,
tend to keep to one class per file, treating them as separate units.

As a side note, one could argue that given the aspx naming convention, the
Winforms naming is wrong, or vice-versa (frmMain.cs, frmMain.Designer.cs and
frmMain.resx, rather than frmMain.frm, frmMain.frm.cs and frmMain.frm.resx)
but they're developed by different teams and haven't been similarised -
can't think of the correct term :)

Hope that makes sense... :)

Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:XM**************@nospamthankyou.spam...
>What's the name of your page? If, for example, it's ProductList.aspx,
>your
code-behind file should be called ProductList.aspx.cs I think.


Ooh, I wonder if that's the reason then? I adopted the convention of
ferret.aspx and ferret.cs for the two pages. I didn't like the .aspx.cs
idea (don't know why), and given that it seemed to be simply one way of
doing it, I picked my own.

<pause for experiment>

Well cut off both my legs and call me Shorty!! It worked. OK, so now I
know how to do it, I'll have to go and change the name of all my pages.
What a pain. I wonder why they insisted on that naming convention. It
seems very restrictive. Why can't I name my files anything I like?

Thanks for the reply.
Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:E2**************@nospamthankyou.spam...
>re:
>> Thanks for the tip, but it didn't work. I tried adding the two files
>
>It works fine for me.
>
>Let's review the mechanics and make sure you're doing what you should.

I did exactly what you said, except that I was adding them to an
existing
web site instead of starting a new project, but that shouldn't be
relevant.

What does the page directive look like in your .aspx file? I tried three
variations, but maybe I'm missing something. Mine looks like...

<%@ Page Language="C#" Debug="true" Src="ProductList_cb.cs"
Inherits="ProductList" %>

As I said, I tried changing Src to CodeBehind and CodeFile, but it
didn't
help.

Thanks for the help. Any further help would be very gratefully received.
Ta ra

>1. Click "Website" on the VS.NET 2005 menu for VWD.
>2. Click "Add Existing Item".
>3. Navigate to the folder where the files exist.
>4. Select your aspx file ( click on it *once* to highlight it ).
>5. Hold the Control key and select the .cs file which corresponds to the
>aspx.
>6. Now you have *both* files highlighted
>7. Click the "Add" button.
>
>Is that what you're doing ?
>
>When I do that, the aspx file is added to my Solution Explorer,
>with the corresponding codebehind .cs file linked to it.
>
>I can see the linked codebehind .cs file by clicking the plus sign (+)
>in front of the aspx file.
>
>
>
>
>
>Juan T. Llibre, ASP.NET MVP
>ASP.NET FAQ : http://asp.net.do/faq/
>Foros de ASP.NET en Español : http://asp.net.do/foros/
>======================================
>"Alan Silver" <al*********@nospam.thanx> wrote in message
>news:UA**************@nospamthankyou.spam.. .
>> Juan,
>>
>> Thanks for the tip, but it didn't work. I tried adding the two files
>> simultaneously as
>> they are (ie with the code-behind file specified using the Src
>> attribute
>> of the page
>> directive) and it didn't work.
>>
>> I then deleted them from the project, changed the .aspx file to use
>> CodeFile (using
>> Notepad) and adding them again, but this didn't work either. I also
>> tried using
>> COdeBehind, but that didn't work.
>>
>> Any other ideas? Thanks for the reply.
>>
>>>re:
>>>> Maybe I didn't explain it clearly enough.
>>>
>>>I understand better now.
>>>
>>>To get the IDE to understand that the files are related,
>>>just select *both* the *.aspx and the *aspx.cs file
>>>at the same time, and add them simultaneously.
>>>
>>>The IDE will display them as you want them to display.
>>>
>>>
>>>
>>>Juan T. Llibre, ASP.NET MVP
>>>ASP.NET FAQ : http://asp.net.do/faq/
>>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>>======================================
>>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>>news:0n**************@nospamthankyou.spam.. .
>>>>>> it recognised the .cs file as being the code-behind for the .aspx,
>>>>>> but didn't change
>>>>>> the
>>>>>> display in the solution explorer. They were still shown as
>>>>>> separate
>>>>>> items.
>>>>>
>>>>>I don't understand. They will *always* be shown as separate items.
>>>>>
>>>>>You can edit *.aspx and *.aspx.cs files separately.
>>>>>Am I missing something ?
>>>>
>>>> Maybe I didn't explain it clearly enough. In the solution explorer,
>>>> you see an entry
>>>> for
>>>> the .aspx file, with a small + sign to the left of the icon. If you
>>>> click the + sign,
>>>> a
>>>> node opens below it for the .cs file.
>>>>
>>>> When I add pre-existing files, they just show as two separate
>>>> top-level nodes in the
>>>> solution explorer. I'm trying to find a way of persuading VWD to put
>>>> the .cs file as a
>>>> node below the .aspx file, so the top-level nodes are (mostly) .aspx
>>>> files.
>>>>
>>>> Does that explain it any better?
>>>>
>>>>>Juan T. Llibre, ASP.NET MVP
>>>>>ASP.NET FAQ : http://asp.net.do/faq/
>>>>>Foros de ASP.NET en Español : http://asp.net.do/foros/
>>>>>======================================
>>>>>"Alan Silver" <al*********@nospam.thanx> wrote in message
>>>>>news:mw**************@nospamthankyou.spam ...
>>>>>> >: add my .aspx and .cs (code-behind) files, but VWD doesn't know
>>>>>> >:which .cs
>>>>>>>: file si the code-behind for any particular .aspx file.
>>>>>>>
>>>>>>> Add an attribute "CodeBehind=<file>.cs" to the "@ Page"
>>>>>>> Directive on the
>>>>>>>top.
>>>>>>
>>>>>> VWD complained at CodeBehind, saying it was no longer supported. I
>>>>>> tried using
>>>>>> CodeFile
>>>>>> instead as the ones VWD generates use that, and then it recognised
>>>>>> the .cs file as
>>>>>> being
>>>>>> the code-behind for the .aspx, but didn't change the display in
>>>>>> solution
>>>>>> explorer.
>>>>>> They were still shown as separate items.
>>>>>>
>>>>>> Any other ideas? Thanks.
>>>>>>
>>>>>> --
>>>>>> Alan Silver
>>>>>> (anything added below this line is nothing to do with me)
>>>>>
>>>>>
>>>>
>>>> --
>>>> Alan Silver
>>>> (anything added below this line is nothing to do with me)
>>>
>>>
>>
>> --
>> Alan Silver
>> (anything added below this line is nothing to do with me)
>
>

--
Alan Silver
(anything added below this line is nothing to do with me)


--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #17
>What's the name of your page? If, for example, it's ProductList.aspx,
your code-behind file should be called ProductList.aspx.cs I think.


OK, I've been contemplating this, and I have another question.

I have a page on which products are displayed. In order to give the web
site owner some flexibility, the page checks a config file and loads the
user control specified. That user control actually does the work of
pulling the product details from the database and setting the visual
controls to the right values. There can be any number of user controls,
although in reality, they are all .ascx files which use one common .cs
code-behind file.

At the moment they are named like this...

ProductStyle1.ascx
ProductStyle2.ascx
ProductStyle3.ascx
....etc...

and the .cs file is named Product.cs. At the moment, I can add and
delete the .ascx files as I wish, and the admin page for the site owner
just looks to see which .ascx files exist and offers them as the choice.

Now, how would I do this in VWD? I really would like it to know (and
show visually) that all of these .ascx files use Product.cs as the
code-behind, but I can't do this by renaming it (say to
ProductStyle1.ascx.cs), as that would a) only allow it to be tied to one
of the .ascx files and b) specifically tie it to that one, meaning that
I couldn't remove the .ascx file later.

Any suggestions? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #18
Without seeing the code (i.e. this might not be suitable) I'd suggest having
a look at Themes to see if they can do anything for you. Can you post
examples of the .ascx and/or explain how they differ?

Jevon
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:NJ**************@nospamthankyou.spam...
What's the name of your page? If, for example, it's ProductList.aspx,
your code-behind file should be called ProductList.aspx.cs I think.


OK, I've been contemplating this, and I have another question.

I have a page on which products are displayed. In order to give the web
site owner some flexibility, the page checks a config file and loads the
user control specified. That user control actually does the work of
pulling the product details from the database and setting the visual
controls to the right values. There can be any number of user controls,
although in reality, they are all .ascx files which use one common .cs
code-behind file.

At the moment they are named like this...

ProductStyle1.ascx
ProductStyle2.ascx
ProductStyle3.ascx
...etc...

and the .cs file is named Product.cs. At the moment, I can add and delete
the .ascx files as I wish, and the admin page for the site owner just
looks to see which .ascx files exist and offers them as the choice.

Now, how would I do this in VWD? I really would like it to know (and show
visually) that all of these .ascx files use Product.cs as the code-behind,
but I can't do this by renaming it (say to ProductStyle1.ascx.cs), as that
would a) only allow it to be tied to one of the .ascx files and b)
specifically tie it to that one, meaning that I couldn't remove the .ascx
file later.

Any suggestions? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)

Nov 19 '05 #19
>Without seeing the code (i.e. this might not be suitable) I'd suggest having
a look at Themes to see if they can do anything for you. Can you post
examples of the .ascx and/or explain how they differ?
At the simplest, you could have two .ascx files that contains exactly
the same HTML and server tags, but laid out slightly differently, eg:-

ProductStyle1.ascx
==============
<%@ Inherits="ShowProduct" CodeBehind="ShowProduct.cs" %>
<asp:Literal ID="litProductName" Text="" RunAt="server" />
<br><img ID="imgPic" src="" border="0" alt="" Runat="Server" />

and ...

ProductStyle2.ascx
==============
<%@ Inherits="ShowProduct" CodeBehind="ShowProduct.cs" %>
<img ID="imgPic" src="" border="0" alt="" Runat="Server" />
<br><asp:Literal ID="litProductName" Text="" RunAt="server" />

Obviously, that's a very much simplified example, but the principle is
there. The .ascx files create different layouts by having the HTML and
server tags in different places. The code-behind file doesn't care where
the server controls are, it just populates them.

The result is that different products on the site can be displayed in
different ways, and the site owner can choose which style to use for any
given product.

Hopefully you can now see why I have multiple .ascx files with just one
code-behind file. I don't think themes would do this as they are more
global, or at least page-specific than my method. I have just one
Products.aspx page that takes a querystring parameter and loads the
appropriate info. Part of that is choosing the right .ascx file.

Does that make it any clearer? Thanks for the reply.
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:NJ**************@nospamthankyou.spam...
>What's the name of your page? If, for example, it's ProductList.aspx,
>your code-behind file should be called ProductList.aspx.cs I think.


OK, I've been contemplating this, and I have another question.

I have a page on which products are displayed. In order to give the web
site owner some flexibility, the page checks a config file and loads the
user control specified. That user control actually does the work of
pulling the product details from the database and setting the visual
controls to the right values. There can be any number of user controls,
although in reality, they are all .ascx files which use one common .cs
code-behind file.

At the moment they are named like this...

ProductStyle1.ascx
ProductStyle2.ascx
ProductStyle3.ascx
...etc...

and the .cs file is named Product.cs. At the moment, I can add and delete
the .ascx files as I wish, and the admin page for the site owner just
looks to see which .ascx files exist and offers them as the choice.

Now, how would I do this in VWD? I really would like it to know (and show
visually) that all of these .ascx files use Product.cs as the code-behind,
but I can't do this by renaming it (say to ProductStyle1.ascx.cs), as that
would a) only allow it to be tied to one of the .ascx files and b)
specifically tie it to that one, meaning that I couldn't remove the .ascx
file later.

Any suggestions? TIA

--
Alan Silver
(anything added below this line is nothing to do with me)



--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 19 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: clintonG | last post by:
VS2005 2.0 Beta 2 noting I've posted (to no avail so far) to the somewhat deadzone at news://microsoft.public.vsnet.ide and am getting ants in my pants for some discussion about this issue. ...
7
by: Frank Rizzo | last post by:
Is it me or is the speed of VS2005 actually slower than VS2003? The startup is pretty bad - even though I changed VS to display an empty environment. When I create a new form and want to change...
10
by: GaryDean | last post by:
A couple of weeks ago I reported a bug in vs2005 where it corrupted projects converted from vs2003 if a 2003 dataset were modified or recreated. Steven Cheng was able to recreate the bug. I ...
1
by: Ben Fidge | last post by:
Can anyone shed some light on why compiling and running web-apps is so slow in VS2005. I have a solution with 3 web-apps, 20 or so library projects and several winforms apps. All in all it totals...
3
by: ohnoonho | last post by:
Hello, I posted this in the C# group but thought maybe the better place would be here since it is happening with website projects so please forgive any cross posting. In my website projects I...
0
by: microdevsolutions | last post by:
Hello Our environment is - pure .NET (ASP.NET, C#.NET, VB.NET) - MCMS (templates, user controls, etc) - Sharepoint (web parts, smart parts, etc) I am wanting to gradually move our...
0
by: induriprakash | last post by:
Hi, We are working on a scientifical related product which is most sensitive towards mathematical functions (even 7th decimal place chang can cause considereble differences in the output values)....
4
by: Tony Girgenti | last post by:
Hello. I developed a VS.NET2003(VB), ASP.NET web application client program with ..NET Framework 1.1, ASP.NET 1.1, IIS 5.1 and WSE 2.0. I tried to migrate it to VS 2005 Pro(VB), Web...
20
by: Iouri | last post by:
Hi everybody, We are currently using VS2003 and now we are in the porcess of upgrading to the next Visual Studio version. Does somebody have a real life experience with VS2008? My boss wants to...
5
by: Kardon Coupé | last post by:
Dear All, I'm bemused, I'm moving an application I've written from VB6 into VS2005, and I'm getting all the fundamentals over before I delve into the hard part, like getting the forms layout...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.