473,320 Members | 1,950 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,320 software developers and data experts.

Response.Write In Class?

Consider the following class named "Constructor.vb" which exists in
C:\Inetpub\wwwroot\ASPX:

Imports System
Imports System.Data
Imports System.Web
Imports System.Web.HttpResponse
Imports System.Web.UI.Page

Namespace cons
Public Class Constructor : Inherits Page
Public Sub Hello()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

When I try to compile the above class (in a folder named "Business"
which is a sub-folder in the "ASPX" folder) using

vbc /t:library /out:Business/Cons.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll Constructor.vb

I get the following 2 errors:

Error1:
------

Type 'Page' is not defined.

pointing to the following line

Public Class Constructor : Inherits Page

Error2:
------

Reference to a non-shared member requires an object reference.

pointing to the following line:

Response.Write("Constructor1")

What am I doing wrong?

Secondly, to use a class in an ASPX page, is it always necessary to
compile it into a DLL & then import it as a namespace in the ASPX page?

Thanks,

Arpan

Sep 20 '06 #1
1 13553

Your first issue:
Error 1: In your Imports System.Web.UI.Page change it to: Imports
System.Web.UI

Error 2: Resolving the first error should most likely resolve this error.

Your second issue:
ASP.NET can automatically compile this class for you on demand, however, to
achieve this you must deploy the .vb file on the web server. Some people
don't like this so they pre-compile it like you did. If you don't have
issues deploying your .vb file, then in your aspx page you can define a Src
attribute setting the filename of the .vb file as your parameter.

<%@ Page language="VB" Src="Constructor.vb" %>

This should work, hopefully I didn't leave anyting out.

"Arpan" <ar******@hotmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Consider the following class named "Constructor.vb" which exists in
C:\Inetpub\wwwroot\ASPX:

Imports System
Imports System.Data
Imports System.Web
Imports System.Web.HttpResponse
Imports System.Web.UI.Page

Namespace cons
Public Class Constructor : Inherits Page
Public Sub Hello()
Response.Write("Constructor1")
End Sub
End Class
End Namespace

When I try to compile the above class (in a folder named "Business"
which is a sub-folder in the "ASPX" folder) using

vbc /t:library /out:Business/Cons.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll Constructor.vb

I get the following 2 errors:

Error1:
------

Type 'Page' is not defined.

pointing to the following line

Public Class Constructor : Inherits Page

Error2:
------

Reference to a non-shared member requires an object reference.

pointing to the following line:

Response.Write("Constructor1")

What am I doing wrong?

Secondly, to use a class in an ASPX page, is it always necessary to
compile it into a DLL & then import it as a namespace in the ASPX page?

Thanks,

Arpan
Sep 20 '06 #2

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

Similar topics

5
by: eddie wang | last post by:
How to convert the following html to asp page using response.write? Thanks. <td align="right"><Font class=content4><%=ars.Fields("REVENUE")%></td> *** Sent via Developersdex...
3
by: PorkyJr | last post by:
Running an asp page that has the following code: <% response.Write MonthName(Month(date)) %> &nbsp; <% response.Write Day(date) %> ,
1
by: Lou | last post by:
I'm using the Response Filter Class in MS KB article 811162 (http://support.microsoft.com/default.aspx?scid=kb;EN-US;811162) to generate a static htm page from an asp.net template page being...
14
by: Hugh Welford | last post by:
Hi - trying to display a memo field using response.write but it truncates it. Is there a size issue with response.write? If so how do I get round it and to be able to display the whole memo field ...
3
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while...
5
by: Michael | last post by:
Hello, I have a separate Database class that handles any database work that all my asp.net pages can use. My problem is, many times I use try/catch to catch errors, and I want to output these...
1
by: Dan | last post by:
Hi I've created a generic 'Report' class that takes a DataView from a DataGrid control and writes it out to the response as a csv file for download. Basically, when a user clicks the download...
2
by: Chris | last post by:
Hi, Is there a macro or add-on to Visual Studio.net that can easily convert HTML to response.write statements with any "s escaped? Handling <%=string%> inline script as concatenation would be...
3
by: Dave Keen | last post by:
Hi all. Hope you can help me. This should be easy but I can't make this work. In brief I am building a page of thumbnails using images held in a SQLServer 2000 database. I do this by creating...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.