Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > common code behind pages

Reply
Thread Tools

common code behind pages

 
 
stumay111
Guest
Posts: n/a
 
      10-02-2005
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.

 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      10-02-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
 
 
 
stumay111
Guest
Posts: n/a
 
      10-02-2005
thanks for the quick answer! I suspected that would be the case... but
wasn't sure of the mechanism (again... RTFM, Stuart)

-s

 
Reply With Quote
 
Mr Newbie
Guest
Posts: n/a
 
      10-02-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can *common* struct-members of 2 different struct-types, that are thesame for the first common members, be accessed via pointer cast to either struct-type? John Reye C Programming 28 05-08-2012 12:24 AM
java.lang.NoSuchMethodError: wm.common.session.Common.getCustRptListFromMax Denny Java 1 05-01-2008 07:33 AM
How to share common code among pages in asp.net 2.0 just_life ASP .Net 0 08-01-2007 05:31 PM
Non-code behind to code behind John ASP .Net 2 02-19-2007 07:08 PM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM



Advertisments