Error "denotes a 'property' where a 'class' was expected"

Hi!

All I want to do ist making the Reponse Object running im my Class. Here the Code:

public class Mywriter {
public Mywriter() {
}
public void mywrite(string text) {
Response.Write(text);
}
}
void page_load(Object sender, EventArgs e) {
Mywriter mytester = new Mywriter();
mytester.mywrite("test");
}

When i run the Code, i get the following error:
Compiler Error Message: CS0118: 'System.Web.UI.Page.Response' denotes a 'property' where a 'class' was expected ( @ "mytester.mywrite("test"); )
But why? Can someone help me? thx a lot!
0
Resu
9/27/2004 1:05:08 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

4 Replies
853 Views

Similar Articles

[PageSpeed] 51

Hi,

Response is a property of Page class. It is not probubly property of your Mywriter class. You can access it through HttpContext.Current.Response. You have to check HttpContext.Current for null in case your class can be used in non web invironment.
Leon Langleyben

MCSD, ASP.NET MVP

Blog
0
llangleyben
9/27/2004 1:50:25 PM
try doing the following it will work...though in your code im not sure why response object is getting correctly associated to System.Web.UI.Page

Pass the Response object as parameter to one of the functions in ur class.:
public class Mywriter {

public Mywriter() {

}

public void mywrite(string text,HttpResponse objResponse) {
objResponse(text);
}
}

void page_load(Object sender, EventArgs e) {
Mywriter mytester = new Mywriter();
mytester.mywrite("test",Response);
}
Regards
Mahesh

0
maheshnt
9/27/2004 2:11:48 PM
Thanks a lot for your help. I just had to write down the complete classpath:


public void mywrite(string text) {
HttpContext.Current.Response.Write(text);
}

It works now.
0
Resu
9/27/2004 2:48:28 PM
Thanks mate. Im changing my code now.

Regards
Mahesh NT
0
maheshnt
9/27/2004 3:13:29 PM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Get "EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'." error when debugger attached
I'm connecting to database using VPN. When i execute web site WITHOUT attching debugger in visual studio, it connects to database fine and get the expected result. BUT if i attach debugger to aspnet_wp.exe in visual studio, i get following error when i try to open sql connection. "EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'."   why and how do i resolve this problem Hi,You have not grant the execute permission for that stored procedure sp_sdidebug. Give execute permission and it should work.Hope this helps.&...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

'100' is an unexpected token. The expected token is '"' or '''.
Dear all,  I have a web form which will call a report viewer and show the report. The report works fine under report server. When call from aspx, it show the below error. Do you know WHY? '100' is an unexpected token. The expected token is '"' or '''. Line 20, position 77. hi rchiu5hk, select rdl/rdlc file in .net IDE and right click then open with xml editor option and then copy the content and then paste it here. so that it may give some better idea on the issue."Mark as Answer" -- on the post that helps youRKChaudary I think ...

'System.Web.UI.Control.Context' denotes a 'property' where a 'class' was expected
I get the following error when trying to compile my project. The call to Context lies in a usercontrol. It works fine when called from a page, but how do I call it from a usercontrol? private User _currentUser = new User(Context.User.Identity.Name); 'System.Web.UI.Control.Context' denotes a 'property' where a 'class' was expected Firefox - The browser you can trust Update: private User _currentUser = new User(Context.User.Identity.Name);Is declared inside the class, not in a function. Like: public class Someclass : System.Web.UI.UserControl { private User _currentUser = new...

Error
Hi  I have not worked in ASP.NET for quite a few months now... and it really shows. Desinging new simple site - nicked some of my old code. I think I must have totally forgotten a few crucial bits here and there. Code below:<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/change_master.master" MaintainScrollPositionOnPostBack ="true" %> <asp:Content ID="mycontent" ContentPlaceHolderID="master_placeholder" Runat="Server"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </asp:Content>  Imports system.Diag...

How do I get around this error "Unable to cast object of type 'System.DBNull' to type 'System.String' "
I am using Visual Developer 2008 Express Edition for the first time, and I keep getting the following error below. The site allows anyone to enter with a valid username and password, but even when I logoff the site I get the same error....like the memory or database is not getting refreshed. I would think that when I initially compile the site that anything left in memory would be flushed out. Can someone please help me to figure this out. Thanks,Ramell P.S. The site is programmed using C#    Unable to cast object of type 'System.DBNull' to type 'System.String&...

Problem with type that causes error "Expected ':' but '=' found.
Hi all I do not understand what's wrong with type keyword This is a completed code for testing only. And the error says 'error "Expected ':' but '=' found.' What could it be? {code} unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) TTemp = (Hot, Warm, Cold); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} end. {code} Clement Yap Tsi Searn wr...

How do I get rid of "conversion from 'size_t' to 'a_sql_uint32'" warnings?
When using Visual C++ 2005 Express to build a 32-bit dll for a SQL Anywhere 10.0.1.3559 CREATE PROCEDURE ... EXTERNAL, I am getting a whole mess of these warnings... 1>.\xxx.cpp(239) : warning C4267: '=' : conversion from 'size_t' to 'a_sql_uint32', possible loss of data How do I get rid of them? They are coming from statements like this... api_odbc_dsn.piece_len = strlen ( odbc_dsn ); ....where (in this particular case) the variables involved are declared thusly... an_extfn_value api_odbc_dsn; char * odbc_dsn; Going back...

I'm getting an error using NavigateURL ='<%# Eval("Url") %>', it works when using NavigateURL="intro.aspx"
I'm getting an error using NavigateURL ='<%# Eval("Url") %>', it works when I use NavigateURL="intro.aspx" Server Error in '/orthoassist' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. Requested URL: /orthoassist/intro.aspx <asp:HyperLink runat="server" ID="hl1" Text=...

Give access to non virtual folder through configuration entry? ERROR: <location> path attribute must be a relative virtual path. It cannot contain any of '?' ':' '\' '*' '"' '<' '>' or '|'.
I have a webpage running under a virtual directory that is mapped to d:/webapplication that produces an excel spreadsheet, the page calls a library object that generates a report and places it in a folder d:/attachments. This folder is not in the virtual directory. When I access the webpage i click a button and it attemps to return the created spreadsheet as a mim content type application/vnd.ms-excel. However i getting redirected back to the login page of the application. Ive also noticed that the excel spreadsheet has not even been created at this location. So assuming this...

Help!!! I have errors "Compiler Error Message: BC30389: 'C' is not accessible in this context because it is 'Private'."
Hi guys! Pls. help me with this one. I know this is very simple and easy for you. i'm just stuck in here for almost two days. I just can't solve this error. Pls reply. Tnx! =) Server Error in '/WebApplication1' Application. -------------------------------------------------------------------------------- Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. hi guys! i'm new in using Crystal Report .Net and I jus...

error with pop calendar " 'files' does not contain a definition for 'PopCalendar1_SelectionChanged'"
i hv import this above my masterpg <%@ Register Assembly="RJS.Web.WebControl.PopCalendar" Namespace="RJS.Web.WebControl" TagPrefix="rjs" %> how can i solve this error?/ pls help me It looks like you may have double clicked on the control or something which would insert a handler SelectionChanged="PopCalendar1_SelectionChanged" in the master page or page, but the function is missing from your code-behind. The other possibility is that you registered the assembly on the master page, but the control is inserted in the .aspx page.  If ...

Javascript Problem i'm getting Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' ....
Hi all,     I'm getting Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)". I have 2 text input field; userId, and userPassword and a login buttonboth input fields have added attribute onkeypress="return clickButton(event,'UserLogin_btnLogin')"and the login button have onclick="return buttonValidateLogin(event,'UserLogin_btnLogin', 'UserLogin_txtUserID', 'UserLogin_txtPassword')"What happens is that when i c...

Web resources about - Error "denotes a 'property' where a 'class' was expected" - asp.net.getting-started

Resources last updated: 1/19/2016 5:05:17 PM