473,326 Members | 2,805 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,326 software developers and data experts.

Codebehind Attribute and Different Paths

Hi All,

I have created a vb file that inherits a System.Web.UI.Page. As I am
against duplicating source code, I have set the Codebehind attribute on all
my aspx pages in the same directory. This works a treat.

Now, I have a sub-directory full of aspx pages that I wish to point to this
wonderful vb file using the Codebehind attribute again. The designer errors
with "The class file '../basepage.vb' specified as the codebehind for
'default.aspx' could not be loaded. Make sure that the codebehind attribute
in the page or control directive properly references an existing code behind
file."

Ok, so the designer does not work for these pages. If I then debug the web
application and visit one of this pages in the sub-directory, it fires the
Page_Load event and runs my code and all is fine.

So, my question is how do I get the designer to work for these pages in the
sub-directory?

Landers
Nov 19 '05 #1
2 2522
I'd suggest not using this strategy as you'll be swimming upstream
against the tools, esepcially when it comes time to move to 2.0.

A better approach would be to put all of your common code into a base
class derived from System.Web.UI.Page, and then derive all your web
form pages from this custom base class. You'll be able to resuse your
code and still have tool support and flexibility to make changes.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 9 Sep 2005 22:49:19 +0100, "landers"
<la****************@hotmail.com> wrote:
Hi All,

I have created a vb file that inherits a System.Web.UI.Page. As I am
against duplicating source code, I have set the Codebehind attribute on all
my aspx pages in the same directory. This works a treat.

Now, I have a sub-directory full of aspx pages that I wish to point to this
wonderful vb file using the Codebehind attribute again. The designer errors
with "The class file '../basepage.vb' specified as the codebehind for
'default.aspx' could not be loaded. Make sure that the codebehind attribute
in the page or control directive properly references an existing code behind
file."

Ok, so the designer does not work for these pages. If I then debug the web
application and visit one of this pages in the sub-directory, it fires the
Page_Load event and runs my code and all is fine.

So, my question is how do I get the designer to work for these pages in the
sub-directory?

Landers


Nov 19 '05 #2
Thanks for your response. I have got it working now.

When I first tried I got the following error when trying to view the page in
a designer:

<<Error Message>>
The file could not be loaded into the Web Foms designer. Please correct the
following error and then try loading it again:

Type Abstract

Make sure all of the classes used in the page are built or references in the
project.
<<End Error Message>>

It turns out that you cannot use MustInherit on the base class. Also, you
must declare the base class as Public, as Friend just does not work.

Thanks again.
"Scott Allen" <sc***@nospam.odetocode.com> wrote in message
news:ft********************************@4ax.com...
I'd suggest not using this strategy as you'll be swimming upstream
against the tools, esepcially when it comes time to move to 2.0.

A better approach would be to put all of your common code into a base
class derived from System.Web.UI.Page, and then derive all your web
form pages from this custom base class. You'll be able to resuse your
code and still have tool support and flexibility to make changes.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 9 Sep 2005 22:49:19 +0100, "landers"
<la****************@hotmail.com> wrote:
Hi All,

I have created a vb file that inherits a System.Web.UI.Page. As I am
against duplicating source code, I have set the Codebehind attribute on
all
my aspx pages in the same directory. This works a treat.

Now, I have a sub-directory full of aspx pages that I wish to point to
this
wonderful vb file using the Codebehind attribute again. The designer
errors
with "The class file '../basepage.vb' specified as the codebehind for
'default.aspx' could not be loaded. Make sure that the codebehind
attribute
in the page or control directive properly references an existing code
behind
file."

Ok, so the designer does not work for these pages. If I then debug the
web
application and visit one of this pages in the sub-directory, it fires the
Page_Load event and runs my code and all is fine.

So, my question is how do I get the designer to work for these pages in
the
sub-directory?

Landers

Nov 19 '05 #3

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

Similar topics

8
by: Krunom Ancini | last post by:
Hi, im just the beginner and im using c#-codebehind in my asp.net-application.... What should i do to make my application work "without" code-behind (without dll.-s in bin-folder)? I was...
2
by: Graham Allwood | last post by:
I'm reading the Essential ASP.NET book by Fritz onion and he says that when VS.NET creates a new .aspx page for you is uses the codebehind attribute on the Page directive rather than the src...
6
by: Maurice Walmsley | last post by:
hi, I hope someone can help me with this please I'm trying to move my codebehind files to a folder other than the one my webform sits in. I've tried changing the 'scr' page level attribute of...
1
by: ani | last post by:
When I try to open the web form page, I get a designer error which says: 'the file could not be loaded into the web forms designer. Please correct the following error and then try loading it...
12
by: A.M | last post by:
Hi, Using VS.NET 2003, If i use SRC page attribute instead of CodeBehind, do i still have intelisence and generally IDE support for that? Thanks, Ali
12
by: Wardeaux | last post by:
All, Wanting to find a way to create web pages to add to my website without having to recompile the codebehind everytime I want to add a new one... Here's the deal: I have a web app that takes...
7
by: Jack | last post by:
Hello, What is the difference between SRC and CODEBEHIND Tags? Example <%@ Page Language="vb" ValidateRequest="false" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" %> or
1
by: Gürkan Demirci | last post by:
Hi, i am using the VisualStudio FormDesigner to create an asp:table. I want to populate an asp:tablecell with different controls at runtime. In the codebehind file, there is an attribute for the...
2
by: aling | last post by:
I create ASP.Net 2 website project in VS 2005, but the solution file always uses absolute path in PhysicalPath attribute. I want to copy the website project anywhere, so the absoluted path not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.