how to add aspx and the class file separately in VS.NET?

  • Thread starter Thread starter BH
  • Start date Start date
B

BH

I'm looking at the source code of the ASP.NET forum sample application. It
has the "code-behind" classes compiled into a separate DLL, totally
separated from the aspx/ascx files. Adding the class files alone in VS.NET
is straightforward, but is there a way configure VS.NET to add aspx/ascx
files alone?
 
I don't understand the question. There are 2 components to an ASPX page: The
Page Template (.aspx) and the CodeBehind (.vb or .cs). The CodeBehind is
compiled into a DLL. The Page Template remains as text. You can't run the
app without both. There is a way to use CodeBehind without compiling to a
DLL. Is that what you're after?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
 
What I was referring to was to develop the "codebehind" classes in a class
library project and compile into a DLL. Then this DLL is referenced in the
web project, which has its own DLL. The web project would largely consists
of the aspx/ascx files. The web project compiles into a small DLL (pretty
much global.asax.cs). The classes in the first DLL are used in the aspx by
registering like this:

<%@ Register TagPrefix="AspNetForums" Namespace="AspNetForums.Controls"
Assembly="AspNetForums" %>
.........
<AspNetForums:LoginProcessor id="abc123" runat="server" />
.........

What I want to know is if I go with this kind of code separation, how do I
add an aspx or ascx without the VS.NET automatically sticks an
aspx.cs/ascx.cs file for me, as I don't need the cs files in the web project
itself, they are defined in the class library project.
 
I'm still having trouble understanding you. A Class Library is just a
collection of classes. It is different than CodeBehind. A CodeBehind class
is the class that completes an ASP.Net Page class, which is made up of a
Template and a CodeBehind class. If your project has a class library, it
would have TWO DLLs with it, one for the Class Library, and one for the
CodeBehind classes of the Pages. If you add a new .aspx page to your
project, you will also need the CodeBehind class, assuming that you want
that page to DO something.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Complex things are made up of
lots of simple things.
 
I figured this out. To add aspx file alone, the VS.NET templates have to be
changed so it shows up as a separate item in the Add New Item list. Web
Forms and User Controls defined as is can only be added with the code behind
file being added at the same time.

Kevin, you can download the ASPNET Forums sample app from asp.net and you'll
see what I mean. Thanks.
 
Back
Top