Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


CodeBehind - Inheritance - Could not load type 'HtmlControls.Form' book example

Posted on 2005-03-21
Medium Priority
Last Modified: 2012-05-05
Hello I am trying to learn ASP.NET using VB.NET from a book called Visual Basic .NET Developer's Guide to ASP.NET, XML, and ADO.NET.  All the examples use this syntax so I believe they have to work.

Here is the error I receive when the page loads into Internet Explorer:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'HtmlControls.Button'.
Source Error:
Line 1:  <%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Button.aspx.vb" Inherits="HtmlControls.Button"%>
Line 2:  <!DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.0 Transitional//EN">
Line 3:  <HTML>
Source File: c:\inetpub\wwwroot\button.aspx    Line: 1
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Here is the code for the button.aspx file:
<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Button.aspx.vb" Inherits="HtmlControls.Button"%>
<!DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.0 Transitional//EN">
<Title>HtmlButton Class </Title>
<Form id="Form1" method="post" runat="server">
<button id="btnClick" title="" type="Button" runat="server">
Click Me</button>

Here is the code for the  button.aspx.vb file:
Public Class Button
Inherits System.Web.UI.Page
Protected WithEvents btnClick As System.Web.UI.HtmlControls.HtmlButton
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnClick.InnerText = "Click Me"
End Sub

Private Sub btnClick_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.ServerClick
Response.Write("You clicked me!")
End Sub
End Class
Question by:tjheroff
  • 3
  • 2
  • 2
  • +2
LVL 12

Expert Comment

ID: 13597982
You should compile button.aspx.vb, and you'll get a dll
copy that dll under directory c:\inetpub\wwwroot\bin

Accepted Solution

imperial_p79 earned 375 total points
ID: 13598351
one of the following 2 will make things work.

1. Change the Inherits to "HtmlControls.button" (note the small case in button)
2. Completely remove the Inherits portion.

hope this would solve the problem.

LVL 26

Expert Comment

ID: 13598639
what is ur project name .. or the namespace given to ur project .. check for it in the menu project->project properties .. in the wondow opened what is the value for the textbox "Root namespace" is it HTMLControls ... Did u compile ur project? i.e. menu .. Build->Build solution ...

by the way, all the names u have used are reserved words and its always better to avoid them . .HTMLControls, Button etc are also used by ASP.net for its own references to controls ...
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 13598671
 your code is running perfectly in my machine , only change is namespace name in Inherits="testAppVB.Button attribute of
<%@ Page Language="VB" AutoEventWireup="false" CodeBehind="Button.aspx.vb" Inherits="HtmlControls.Button"%>

make sure that HtmlControls is your namespace name
LVL 26

Expert Comment

ID: 13598684
rashmitodkar, seems like u landed to the same conclusion that i have already asked tjheroff to check :-)

Expert Comment

ID: 13598695
:) i think we two are writting our comments at the same tip of time . becoz when i opened this page it did not have your comment :)

Author Comment

ID: 13603935
Removing the "inherits" worked.   Thanks!
LVL 26

Expert Comment

ID: 13608902
am suprised how removing the inherits would work .. did the code-behind code also execute properly after removing the inherits statement? Could you please explain?

This is what MSDN says about those attributes in the page directive (@Page ..)
The Codebehind, Inherits, and Src Attributes
In Web Forms that use code-behind files, the @ Page directive (or @ Control in user control files) contains attributes that specify the relationship of the .aspx file and its code-behind file. These attribute are:

Codebehind   In Visual Studio, this attribute references the name of a file that contains the class for the page. For example, if you create a Web Forms page in Visual Studio called WebForm1, the Codebehind attribute will point to WebForm1.aspx.vb or WebForm1.aspx.cs. This attribute is used only by the Visual Studio Web Forms Designer. It tells the designer where to find the page class so that the designer can create an instance of it for you to work with. The attribute is not used at run time.
Inherits   Identifies the class from which the page derives. In Visual Studio, this points to a class in the project assembly (.dll), as shown in the diagram above.
So how does ur code work??? i.e. if u have code in the .vb file

Author Comment

ID: 13612061
Rejojohny - thank you for the follow up question.  But, I am unable to answer the question.  I am new to ASP.NET and VB.NET and am trying to understand what is going on as well - this is an example in the book I mentioned and that I couldn't get it to work.  I am hoping that as I get through the book I will "get it".

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview
Suggested Courses
Course of the Month11 days, 4 hours left to enroll

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question