473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I use my own referenced classes in an asp.net page?

I have added several classes to an ASP.net project via the PROJECT>ADD
CLASS menu.

When I try to use them in the main page it fails with a type not found
error.
What gives? Can't you access code in classes which you have added to
the project?

Here's the code:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TranslatorSearchScreen.aspx.vb"
Inherits="TranslatorSearch.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>Translator Search Screen</title>
</head>
<body MS_POSITIONING="GridLayout">

<h1> Translator Search Screen </h1>
<%
dim strAction as string
strAction = request.form("Action")
select case strAction
case "Search"
dim x as clsZ
end select

%>

<form id="Form1" method="post" runat="server">

<input type = "submit" value = "Search" id=btnSearchname =
"Action">

</form>
</body>
</html>

-----------------------
Public Class MainPage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub

End Class

Public Class clsZ

End Class
Nov 18 '05 #1
3 960
In order to use a class you developed in another class, you have to:

1. Add the Project to your solution (as you already have)
2. Add a Reference to the project in the class's References
3. (Optional) Add an Imports Statement to your code (unless you want to
reference the whole namespace hierarchy when using the class)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Bodza Bodza" <bo*****@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
I have added several classes to an ASP.net project via the PROJECT>ADD
CLASS menu.

When I try to use them in the main page it fails with a type not found
error.
What gives? Can't you access code in classes which you have added to
the project?

Here's the code:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TranslatorSearchScreen.aspx.vb"
Inherits="TranslatorSearch.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>Translator Search Screen</title>
</head>
<body MS_POSITIONING="GridLayout">

<h1> Translator Search Screen </h1>
<%
dim strAction as string
strAction = request.form("Action")
select case strAction
case "Search"
dim x as clsZ
end select

%>

<form id="Form1" method="post" runat="server">

<input type = "submit" value = "Search" id=btnSearchname =
"Action">

</form>
</body>
</html>

-----------------------
Public Class MainPage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub

End Class

Public Class clsZ

End Class

Nov 18 '05 #2
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TranslatorSearchScreen.aspx.vb"
Inherits="TranslatorSearch.WebForm1" %>

Do you have a class "WebForm1" defined, because that is what its trying to
find with this line. In this example you probably just need to replace
TranslatorSearch.WebForm1 with TranslatorSearch.MainPage.

And what is this!

<%
dim strAction as string
strAction = request.form("Action")
select case strAction
case "Search"
dim x as clsZ
end select

%>

no no! :-)

--Michael

"Bodza Bodza" <bo*****@hotmail.com> wrote in message
news:35**************************@posting.google.c om...
I have added several classes to an ASP.net project via the PROJECT>ADD
CLASS menu.

When I try to use them in the main page it fails with a type not found
error.
What gives? Can't you access code in classes which you have added to
the project?

Here's the code:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="TranslatorSearchScreen.aspx.vb"
Inherits="TranslatorSearch.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html>
<head>
<title>Translator Search Screen</title>
</head>
<body MS_POSITIONING="GridLayout">

<h1> Translator Search Screen </h1>
<%
dim strAction as string
strAction = request.form("Action")
select case strAction
case "Search"
dim x as clsZ
end select

%>

<form id="Form1" method="post" runat="server">

<input type = "submit" value = "Search" id=btnSearchname =
"Action">

</form>
</body>
</html>

-----------------------
Public Class MainPage
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

End Sub

End Class

Public Class clsZ

End Class

Nov 18 '05 #3
Thanks guys I have it working now.
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: craig | last post by:
Is it possible to step into the code of a referenced .net assembly from within a project that is being debugged? Thanks!!!
3
by: Jimi | last post by:
What do I need to do to get details of an assembly that is not referenced by an app? I don't even know the classes contained in the assembly. If the assembly is referenced and I know the...
3
by: Jeff Cooper | last post by:
Hey Folks, I have a bunch of aspx pages in a solution. One of these pages, call it header1.aspx, has it's code behind in header1.aspx.vb. Another, header2.aspx, has header2.aspx.vb. When I...
5
by: Rich | last post by:
Hi, I have a project written in asp.net which has a few web pages. The project has been compiled into a dll and now I am referencing that dll in another project. How can I get one of the web...
1
by: andrew | last post by:
I was earlier trying to persist a windows forms control to disk using the binary formatter class. I have devised a workaround, however I have Classes added in as references to my project which...
14
by: Jamey Shuemaker | last post by:
Greetings all, I've been reading for the last couple hours posts on this site and various MS sites about reference libraries and class modules. System: Windows 2K running an A2K db with...
0
by: rajeshmoorthy | last post by:
Hi INTRO : I have a project with a login screen and the menu screen. The menu is built at run time based on the users access permissions. My forms are built as classes in various assemblies. ...
3
by: ma79ash | last post by:
Language :: VS.NET/ C# The type 'frm_data.frm_data' is defined in an assembly that is not referenced. You must add a reference to assembly I have a Frm_sol solution, which consists on 2...
4
by: Christian Joergensen | last post by:
Hello I stumpled upon this "feature" during my work tonight, and found it a bit confusing: .... class C: .... foobar = 42 .... .... <class __main__.C at 0xb7cf735c>
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.