473,387 Members | 1,493 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,387 software developers and data experts.

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

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

Nov 19 '05 #1
3 943
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

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> schreef in bericht
news:el**************@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

Nov 19 '05 #2
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


Nov 19 '05 #3
It looks like partial classes really are 'partial' when a 'part' must be
here and a 'part' must be there. :-)

<%= Clinton Gallagher

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:86**********************@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


Nov 19 '05 #4

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

Similar topics

6
by: William Gill | last post by:
A short while ago someone posted that(unlike the examples) you should use Tk as the base for your main window in tkinter apps, not Frame. Thus : class MyMain(Frame): def __init__(self,...
3
by: Brad Burke | last post by:
From a windows .Net app, I need to 1) check if MSAccess is already open to a certain Access application. If so, then open a form and find a certain record. 2) If not open, then open MSAccess and...
14
by: Salad | last post by:
On the computer side of the businees there is me, the developer. Another person's role is that of the idea man...the person that knows the business and requirements and issues for the business. ...
0
by: Mark Rae | last post by:
Hi, I'm writing a WinForms MDI app in C# and, with the valuable assistance of various contributors in this forum, I have successfully got it to prevent loading multiple instances of itself by...
1
by: Michael C | last post by:
Someone at work told me that he has estimated it is taking him 5 to 10 times longer to write an app as a web app instead of windows app. He's been working on it for 18 months and reckons he could...
6
by: metiu | last post by:
Say I have a console app that does something in three steps: - opens a file - transfers the file through a serial port - does some elaborations and I want to build a GUI around it that, for...
4
by: Mario | last post by:
I have a C# app that runs script files. The app is launched using a command line argument to indicate which script should run. Most scripts are run indefinitely in a loop and periodically perform...
0
by: Robin Yarnell | last post by:
Hello, I need to watch a specific external app to see if it is being used but, don't know how to go about it. The app can either be launched from my app or can already be launched and then my app...
2
by: cj | last post by:
I run two instances of an application on a pc at one time. I want them to assume app A and app B identities. If I check for a previous instance of the app running when the app starts I can...
0
by: Sergio Montero | last post by:
Hi, I've been googling for a while trying to figure out how to solve this problem, pleasy, I'll appreciate any sugestions. I have a Winforms App that should work Online and Offline. Online...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.