Error with GUI HTML designer using a custom base code-behind class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I was working on converting an example pattern from C# to VB.NET for Page Controller in http://msdn.microsoft.com/library/d...en-us/dnpatterns/html/EspServicesPatterns.asp (Web Service Patterns) when I ran into a nasty bug. I have not tried just setting up a project with their C# to see if it works. We are a VB shop and I'd like to make a case for using this pattern. But not if there is some weird sequence to get it to work.

1) I create a web app project.

2) I add a vb class file with this code:
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class BasePage
Inherits System.Web.UI.Page

End Class

3) I build the solution.

4) I go to the code behind page of WebForm1.aspx and change the Inherited class from System.Web.UI.Page to BasePage

5) I switch over to the designer page and I receive the following error:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file:

WebForm1 --- The base class 'PageController.BasePage' could not be loaded. Ensure the assembly has been referenced or built if it is part of the project.

Thanks!
 
Try building your project and afterwards it will work just fine. Naturally, the design view does not work for a base class that does not yet exist. A better solution would be to put BaseClass in another assemly and then reference this assembly.

Regards, Jakob.
 
Hi,

As for the error you encountered when trying view a webpage indesignvidw
which is derived from a custom base page class(inherit System.Web.UI.Page),
I think Jakob's suggestion is reasonable. And I've also done a test on
myside. Are you put the custom base page class's source file(class.vb)
together with the other pages and codebehinds in the web project? If so,
you need to build the web project first so as to make the base page class
existing in the web project's main assembly. If not, since the VS.NET can't
find the class in the existing asemlies so when try lanuch an instance of
the base class when we swtich into design-view you'll get the error.
In addition, you can also try create another class library project to
centralize all the base classes and build them into assembly separatly and
finally reference them by adding the assembly as reference in the web
project.

Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Hi ,

Thanks for the followup. Yes, the copy local make the library assembly be
copied to the main web project's
assembly directory so that is can be referenced locally without related to
the library assembly's project. Anyway, what we need to ensure is just when
we need to view a page which derived a custom page class in design-view,
its custom page class should be avaliable in the existing assembly so that
IDE can find it and instance it.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Back
Top