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

code behind problems in vs.net 2003

hey all,

im building a asp.net project in vs.net. Is there a way to have the
codebehind files sit in a different folder outside the website folder
altogether?

example:
The aspx files are in this directory
c:\inetput\wwwroot\testapp

the code behind code must be in this directory
c:\projects\testapp\src\com\tietronix\testapp\code behind

where the namespace is "com.tietronix.testapp.codebehind"

I have tried these steps with no success.
1) changed the namespace in the aspx.cs file to the appropiate one.
2) changed the @page decl to

Page language="c#"
Codebehind="c:\projects\testapp\src\com\tietronix\ testapp\codebehind\WebForm
1.aspx.cs" AutoEventWireup="false"
Inherits="com.tietronix.virtualastronaut.codebehin d.WebForm1"
If this is possible outside of vs.net using a simple text editor - that
would be great as well.

Since im new to the namespace and codebehind concepts, id really appreciate
it if i could get a example that i was able to see.

thanks in advance for your help!
girish

Nov 18 '05 #1
5 1468
Hi,

You can certainly change the default namespace name to fit your needs. But
you can not change the location of the code behind file by modifying the
CodeBehind to includes the full path. This is the MSDN doc for CodeBehind
Attribute:
************************************************** **************************
******************************
CodeBehind
Specifies the name of the compiled file that contains the class associated
with the page. This attribute is used by the Visual Studio .NET Web Forms
designer. It tells the designer where to find the page class so that the
designer can create an instance of it for you to work with at design time.
For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.
************************************************** **************************
*******************************

You should not keep aspx and codebehind source file in seprate folders.
Both of them are part of a page entity.

Jiange Sun

Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only.

Nov 18 '05 #2
Hi Girish,

Thanks for posting in the community! From your description, you'd like to
set the codebehind file and the aspx file in separate folders, also you're
wanting some information or guides on using the code-behind file when
developing ASP.NET web page.

As for the first question, I quite agree with Jiange's suggestion. Since
the codebehind file is generated for us help develop the web pages more
conveniently at design time, it's better to make them together within the
same location.
And I've searched some references and tech articles on the description and
how to use the "code-behind" mode to develop ASP.NET web pages with VS.NET,
you may have a check to see whether they're helpful to you. Here are the
web links to them:

#Web Forms Code Model
http://msdn.microsoft.com/library/en...msCodeModel.as
p?frame=true

#Developing User Controls in a Code-Behind File
http://msdn.microsoft.com/library/en...lopingusercont
rolsincode-behindfile.asp?frame=true

#INFO: ASP.NET Code-Behind Model Overview
http://support.microsoft.com/default...b;en-us;303247

#HOW TO: Work with Code-Behind Class Files in an ASP.NET Application by
Using Visual C# .NET
http://support.microsoft.com/default...b;en-us;308143

If you have any questions or need any further help, please feel free to
post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3
Thanks for the replies guys. I understand. Theres only one problem yet to be
ironed out in my mind. The code behind file is a class. Classes have
namespaces. For some reason I have a problem if I cant declare a class to be
in a namespace of my choice. I just cant seem to flush that from my system
that your not really supposed to do that.

If i want all source files to be in a namespace called
com.tietronix.testapp, how would i do that for the codebehind since it does
*not* sit in a directory structure of the format /com/tietronix/testapp BUT
sits in the web directory which is c:\inetpub\wwwroot\testweb

And thats another problem I have with VS.net. Why does it not allow me to
choose a directory on the local machine for my asp.net source files and on
build time - allow me to publish to a webserver? I want to isolate my source
files and my deployment files. Cause when you deploy, you dont need the
codebehind classes. you just need the assembly. I like to maintain this
directory structure since all my source files tend to sit in vss and src and
build files intermingling are just my pet peeves.

thanks. Im confused and I guess there is more than one q here.

If you cant answer them - thats ok. Everything slowly becomes clear anyways
after a few weeks of development. This is my first week of developing on the
..net platform.

thanks for your help.
girish
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:gD**************@cpmsftngxa07.phx.gbl...
Hi Girish,

Thanks for posting in the community! From your description, you'd like to
set the codebehind file and the aspx file in separate folders, also you're
wanting some information or guides on using the code-behind file when
developing ASP.NET web page.

As for the first question, I quite agree with Jiange's suggestion. Since
the codebehind file is generated for us help develop the web pages more
conveniently at design time, it's better to make them together within the
same location.
And I've searched some references and tech articles on the description and
how to use the "code-behind" mode to develop ASP.NET web pages with VS.NET, you may have a check to see whether they're helpful to you. Here are the
web links to them:

#Web Forms Code Model
http://msdn.microsoft.com/library/en...msCodeModel.as p?frame=true

#Developing User Controls in a Code-Behind File
http://msdn.microsoft.com/library/en...lopingusercont rolsincode-behindfile.asp?frame=true

#INFO: ASP.NET Code-Behind Model Overview
http://support.microsoft.com/default...b;en-us;303247

#HOW TO: Work with Code-Behind Class Files in an ASP.NET Application by
Using Visual C# .NET
http://support.microsoft.com/default...b;en-us;308143

If you have any questions or need any further help, please feel free to
post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #4
hmmmm

namespace has nothing to do with directory structure?
meaning if I had a namespace of com.tietronix.codebehind, the file declared
of that namespace need not be in a folder called
......./com/tietronix/codebehind/ ?

thanks,
girish
"Jiange Sun [MSFT]" <ji*****@online.microsoft.com> wrote in message
news:Y4**************@cpmsftngxa07.phx.gbl...
Hi,

You can certainly change the default namespace name to fit your needs. But
you can not change the location of the code behind file by modifying the
CodeBehind to includes the full path. This is the MSDN doc for CodeBehind
Attribute:
************************************************** ************************** ******************************
CodeBehind
Specifies the name of the compiled file that contains the class associated
with the page. This attribute is used by the Visual Studio .NET Web Forms
designer. It tells the designer where to find the page class so that the
designer can create an instance of it for you to work with at design time.
For example, if you create a Web Forms page in Visual Studio called
WebForm1, the designer will assign the Codebehind attribute the value of
WebForm1.aspx.vb, for Visual Basic, or WebForm1.aspx.cs, for C#. This
attribute is not used at run time.
************************************************** ************************** *******************************

You should not keep aspx and codebehind source file in seprate folders.
Both of them are part of a page entity.

Jiange Sun

Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights. Please reply to newsgroups only.

Nov 18 '05 #5
Hi Girish,
Have you viewed my last reply or have you got any ideas on this problem?
Please check out my suggestions in the last reply. If you need any further
help, please feel free to let me know.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #6

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

Similar topics

1
by: Joe | last post by:
I made a template for webforms. The template.inf calls for two files the ..ascx and the .cs. The .cs template file's code does not get written out to the newly added control? Joe
8
by: edster | last post by:
A *lot* of our teams code is being deleted from the InitializeComponent() section of a winform, such as Grid settings, event handler hooks, layout settings etc. This mainly seems to happen to 3rd...
10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
5
by: Dan | last post by:
We have a simple site. It's a frameset with two frames a left and a right. The left frame is essentially a list of records from a database (using a server-side repeater control). When you click...
2
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
21
by: Sandy | last post by:
Hello - I am using Visual Studio .Net. I need an example of how to construct a class that can be used throughout a project where I can include its subs and functions in various pages in the...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.