Home All Groups Group Topic Archive Search About

2.0 App-Code Folder Support for 'Code-Behind'

Author
9 Jun 2005 11:30 PM
clintonG
I've posted to the forums but we're not making progress there yet so maybe,
just maybe somebody has this figured out...


When VS2005 creates a new Web Form with code placed in a separate file we
get the following:

WebForm1.aspx
WebForm1.aspx.cs

Both files are in the root of the project directory. I move WebForm1.aspx.cs
to the App_Code folder.

To test I declared Label1 in WebForm1.aspx and attempt to modify the Label1
text property as Label1.Text = Hello World"; in the Page_Load event of
WebForm1.aspx.cs but an error results.

Apparently moving the .cs files to App_Code folder not supported?
We've tried pathing and using the new page directive syntax but perhaps
incorrectly?
Any comments on this? It seems broken as all code is 'sposta' be within a
partial class so why wouldn't the compiler know how to cope when the .cs
files are moved to the App_Code folder?


<%= Clinton Gallagher

Author
9 Jun 2005 11:54 PM
Arjen
Hi Clinton,

Look in the WebForm1.aspx file at line one "... CodeFile="WebForm1.aspx.cs"
....", is this correct?

Nope, change it to App_Code\WebForm1.aspx.cs.

Hope this helps,
Arjen



Show quoteHide quote
"clintonG" <csgallag***@REMOVETHISTEXTmetromilwaukee.com> schreef in bericht
news:elBDHtUbFHA.3144@TK2MSFTNGP14.phx.gbl...
> I've posted to the forums but we're not making progress there yet so
> maybe, just maybe somebody has this figured out...
>
>
> When VS2005 creates a new Web Form with code placed in a separate file we
> get the following:
>
> WebForm1.aspx
> WebForm1.aspx.cs
>
> Both files are in the root of the project directory. I move
> WebForm1.aspx.cs to the App_Code folder.
>
> To test I declared Label1 in WebForm1.aspx and attempt to modify the
> Label1 text property as Label1.Text = Hello World"; in the Page_Load event
> of WebForm1.aspx.cs but an error results.
>
> Apparently moving the .cs files to App_Code folder not supported?
> We've tried pathing and using the new page directive syntax but perhaps
> incorrectly?
> Any comments on this? It seems broken as all code is 'sposta' be within a
> partial class so why wouldn't the compiler know how to cope when the .cs
> files are moved to the App_Code folder?
>
>
> <%= Clinton Gallagher
>
>
>
Are all your drivers up to date? click for free checkup

Author
10 Jun 2005 1:01 PM
Brock Allen
The App_Code is meant for non-codebehind related code, if that makes sense.
So shared common functionality that's not specific to any one page. The compilation
model in ASP.NET 2.0 doesn't prefer the codebehind file in the App_Code folder.
As you've discovered, it wants the codebehind just in the same directory.

Now, you *can* move it there if you'd like, but then you should remove the
CodeFile attribute from your ASPX. This, unfortunately, will disable the
partial support and thus the automatic server side control declarations in
the codebehind.

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> I've posted to the forums but we're not making progress there yet so
> maybe, just maybe somebody has this figured out...
>
> When VS2005 creates a new Web Form with code placed in a separate file
> we get the following:
>
> WebForm1.aspx
> WebForm1.aspx.cs
> Both files are in the root of the project directory. I move
> WebForm1.aspx.cs to the App_Code folder.
>
> To test I declared Label1 in WebForm1.aspx and attempt to modify the
> Label1 text property as Label1.Text = Hello World"; in the Page_Load
> event of WebForm1.aspx.cs but an error results.
>
> Apparently moving the .cs files to App_Code folder not supported?
> We've tried pathing and using the new page directive syntax but
> perhaps
> incorrectly?
> Any comments on this? It seems broken as all code is 'sposta' be
> within a
> partial class so why wouldn't the compiler know how to cope when the
> .cs
> files are moved to the App_Code folder?
> <%= Clinton Gallagher
>
Author
10 Jun 2005 10:02 PM
clintonG
It looks like partial classes really are 'partial' when a 'part' must be
here and a 'part' must be there. :-)

<%= Clinton Gallagher



Show quoteHide quote
"Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
news:868485632539908751698096@msnews.microsoft.com...
> The App_Code is meant for non-codebehind related code, if that makes
> sense. So shared common functionality that's not specific to any one page.
> The compilation model in ASP.NET 2.0 doesn't prefer the codebehind file in
> the App_Code folder. As you've discovered, it wants the codebehind just in
> the same directory.
>
> Now, you *can* move it there if you'd like, but then you should remove the
> CodeFile attribute from your ASPX. This, unfortunately, will disable the
> partial support and thus the automatic server side control declarations in
> the codebehind.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>> I've posted to the forums but we're not making progress there yet so
>> maybe, just maybe somebody has this figured out...
>>
>> When VS2005 creates a new Web Form with code placed in a separate file
>> we get the following:
>>
>> WebForm1.aspx
>> WebForm1.aspx.cs
>> Both files are in the root of the project directory. I move
>> WebForm1.aspx.cs to the App_Code folder.
>>
>> To test I declared Label1 in WebForm1.aspx and attempt to modify the
>> Label1 text property as Label1.Text = Hello World"; in the Page_Load
>> event of WebForm1.aspx.cs but an error results.
>>
>> Apparently moving the .cs files to App_Code folder not supported?
>> We've tried pathing and using the new page directive syntax but
>> perhaps
>> incorrectly?
>> Any comments on this? It seems broken as all code is 'sposta' be
>> within a
>> partial class so why wouldn't the compiler know how to cope when the
>> .cs
>> files are moved to the App_Code folder?
>> <%= Clinton Gallagher
>>
>
>
>

Bookmark and Share