473,407 Members | 2,546 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.

common code behind pages

I am working in VS 2003, using VB.NET.

I have a series of pages with forms on them, an application for a DOT
number for motor carriers. The code behind them iterates through the
controls on the form, each of which have the same id as the field in
the SQL Server database they post to, so I don't have to get the data
from each field specifically.

So I use the same code for each page. I have tried to set the
CodeBehind to point to that page, but VS.NET keeps creating new
<pagename>.aspx.vb pages when I create a new page and somehow attaches
the page to the wrong CodeBehind. The project runs, but I keep getting
compiler errors.

In the old days, I'd just edit the make file... sigh.

Where are these bogus pages getting attached?

here's the compiler error:

C:\Inetpub\wwwroot\MCCI\MCCIFormPg4.aspx.vb Unable to open module file
'C:\Inetpub\wwwroot\MCCI\MCCIFormPg4.aspx.vb': The system cannot find
the file specified.

here's the CodeBehind statement from MCCIFormPg4.aspx:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="MCCIForm.aspx.vb" Inherits="MCCI.MCCI"%>

Not only that, but whenever I make a new page, it adds a new class to
the list for that page. I don't want this - I want them to use the same
class. I guess I should have made a distinct class to hold the code
that parses the fields, and let VS.NET create it's own classes, and
then imported the generic class into the page itself... maybe I should
RTFM.

Nov 19 '05 #1
3 3353
Hi, Stu.

re:
I want them to use the same class.
I guess I should have made a distinct class
The best solution for this, in ASP.NET 1.1, is to compile your
class file to an assembly, placing it in the bin directory,
and importing the Namespace in your aspx pages.

That allows you to instantiate your classes in any aspx page.

In ASP.NET 2.0, you have a choice.

You can either do the same as you do for ASP.NET 1.1,
or you can place the class file ( *.vb or *.cs ) in the
application's App_Code directory.

ASP.NET 2.0 will compile any class file it finds there,
and you can reference the namespace/classes in them in your aspx files.


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/
======================================
"stumay111" <st*******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...I am working in VS 2003, using VB.NET.

I have a series of pages with forms on them, an application for a DOT
number for motor carriers. The code behind them iterates through the
controls on the form, each of which have the same id as the field in
the SQL Server database they post to, so I don't have to get the data
from each field specifically.

So I use the same code for each page. I have tried to set the
CodeBehind to point to that page, but VS.NET keeps creating new
<pagename>.aspx.vb pages when I create a new page and somehow attaches
the page to the wrong CodeBehind. The project runs, but I keep getting
compiler errors.

In the old days, I'd just edit the make file... sigh.

Where are these bogus pages getting attached?

here's the compiler error:

C:\Inetpub\wwwroot\MCCI\MCCIFormPg4.aspx.vb Unable to open module file
'C:\Inetpub\wwwroot\MCCI\MCCIFormPg4.aspx.vb': The system cannot find
the file specified.

here's the CodeBehind statement from MCCIFormPg4.aspx:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="MCCIForm.aspx.vb" Inherits="MCCI.MCCI"%>

Not only that, but whenever I make a new page, it adds a new class to
the list for that page. I don't want this - I want them to use the same
class. I guess I should have made a distinct class to hold the code
that parses the fields, and let VS.NET create it's own classes, and
then imported the generic class into the page itself... maybe I should
RTFM.

Nov 19 '05 #2
thanks for the quick answer! I suspected that would be the case... but
wasn't sure of the mechanism (again... RTFM, Stuart)

-s

Nov 19 '05 #3
LOL

I've had RTFM said to me so many times over the early years, that I
eventually stopped asking for the most part.

Regards Mr N.
"stumay111" <st*******@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
thanks for the quick answer! I suspected that would be the case... but
wasn't sure of the mechanism (again... RTFM, Stuart)

-s

Nov 19 '05 #4

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

Similar topics

6
by: nospam | last post by:
I just read on Slash Dot about partial types. Now, is it possible to have a code behind split over two pages but still referencing the same .aspx file??? If so, that would be really nice as...
1
by: richardlane | last post by:
Hi, basic question here - I'm struggling with the transfer from asp to asp.net a bit, especially in seeing the 'bigger picture' of how things are best structured. I have a website made up...
3
by: Jeff Cooper | last post by:
Hey Folks, I have a bunch of aspx pages in a solution. One of these pages, call it header1.aspx, has it's code behind in header1.aspx.vb. Another, header2.aspx, has header2.aspx.vb. When I...
2
by: Wayne J | last post by:
I have 3 pages, each with 2 tables (tblNew and tblConfirm), because these 2 tables are affected by the same code, I thought if I used an inherited class defining these variables along with the...
2
by: Tony | last post by:
I have created a few pages in asp.net with in line code and have decided to convert them to use code behind pages. I have some classes that are common to more than one page. How do I add a...
7
by: J Smithers | last post by:
I have several ASPX pages (with code-behind logic) that I reuse amongst many Web sites on the same production server. Currently each Web site has its own copy of these aspx pages. I was thinking...
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)...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
4
by: jmacduff | last post by:
I have a set of pages ( about 10 ) that all have the same controls at the top, however I am unable to put the controls the master page for the site since the other 50 pages dont have the controls....
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
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.