By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,367 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,367 IT Pros & Developers. It's quick & easy.

Codebehind Attribute and Different Paths

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.