Thank you for any attempt to help me. My problem: After creating a Web form page that works with no errors, I try...
to reopen it later and get this error message:
"The file failed to load in the Web Form designer. Please correct the following error, then load it again: Visual Studio cannot open a designer for that file because the class within it does not inherit from a class that can be visually designed."
My main page has this at the top:
<%@ Page Language="vb" src="WebForm2.aspx.vb" Inherits="WebForm2"%>
And my code behind page has:
Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Web.UI.WebControls.DropDownList Imports System.Web.UI.WebControls.Button Imports System.Data Public Class WebForm2 Inherits Page ( also tried Inherits System.Web.UI.Page ) Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList Protected WithEvents Button1 As System.Web.UI.WebControls.Button
I believe the problem is in the code behind page, because if I change <%@ Page Language="vb" src="WebForm2.aspx.vb" Inherits="WebForm2"%> to <%@ Page Language="vb" %>, there is no problem.
Again any help you can offer would be greatly appreciated. Thank you.
The problem definitely is the @Page directive. VB.NET adds all classes to the default namespace specified for the project properties, like MyWebApp, which usually is both the application name and the compiled assembly name. This namespace must be added to the Inherits attribute, such as: Inherits="MyWebApp.WebForm2." That may do the trick.
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ...continue reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers.continue reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.