|
-
Sep 17th, 2004, 05:33 AM
#1
Thread Starter
New Member
Help on use of class in ASP.NET!
I am learing to use vb.net class for my web applications. The pages I am starting with are pretty simple since I just want to figure out how to using the class for my web applicatons. I created a simple .aspx webform page and wrote a namespace in a separate .vb file which contains the class I defined. Both files are located under the same project folder. But when I try to view the .aspx webform in browser, I got the error message which says BC30002: Type 'Database' is not defined (Database is the class I created in .vb file) Is there anyone can help me out? Really appreciate it!! I am pasting my code as follows.
1. database.vb
Imports System
Imports System.Data
Imports System.Data.OleDb
Namespace MYNAME
Public Class Database
End Class
End Namespace
2. Here is the code for my .aspx file
WebForm1.aspx
<%@ Page Language="vb" %>
<%@ Import Namespace="MYNAME" %>
<script runat="server">
sub Page_Load (obj as object, e as eventargs)
dim objDatabase as new Database
lblmessage.text="object created"
end sub
</script>
<HEAD>
<title>WebForm1</title>
</HEAD>
<HTML>
<body>
<asp:Label id="lblMessage" style="Z-INDEX: 101; LEFT: 96px;
POSITION: absolute; TOP: 96px"
runat="server" Width="104px" Height="24px">
</asp:Label>
</body>
</HTML>
-
Sep 22nd, 2004, 10:48 PM
#2
Member
It appears as though you have not compiled your VB source file into a DLL for the Import directive to work [b]and[b] you are not referencing the source file anywhere in the .aspx file for the server to read.
In other words, either compile the source file into a DLL, then place that DLL in the Bin\ folder of the directory, OR, create a source file for the .aspx page itself and include your code in the namespace hierarchy.
T
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|