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

Response.Write's unusual behavior (i think)

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 calling the same method same way except
for creating object instead directly calling the method?
i get this when trying to do that:-

**************************************************
Response is not available in this context.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Response is not available in
this context.

Source Error:

Line 32: for (a=1; a<8; a++)
Line 33: {
Line 34: Response.Write("<H"+a.ToString()+">Heading
<H"+a.ToString()+">");
Line 35:
Line 36: }
**************************************************

i'm new to the .NET stuff and was playing around with it when came across
above......let me know if i'm doing something wrong there.
Thanks in advance.

Best Regards,
Farooq Khan
Nov 17 '05 #1
3 1676
Hi Farooq,

Where is this code in your application? The Reponse object is not
available in some areas.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
From: "Farooq Khan" <fa*********@hotmail.com>
Subject: Response.Write's unusual behavior (i think)
Date: Thu, 23 Oct 2003 21:45:30 +0500
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <u1**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 202.141.251.2
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:186093
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

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 calling the same method same way except
for creating object instead directly calling the method?
i get this when trying to do that:-

************************************************* *
Response is not available in this context.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Response is not available in
this context.

Source Error:

Line 32: for (a=1; a<8; a++)
Line 33: {
Line 34: Response.Write("<H"+a.ToString()+">Heading
<H"+a.ToString()+">");
Line 35:
Line 36: }
************************************************* *

i'm new to the .NET stuff and was playing around with it when came across
above......let me know if i'm doing something wrong there.
Thanks in advance.

Best Regards,
Farooq Khan


Nov 17 '05 #2
Why do you instantiate WebApplication7.WebForm2?
It's done by ASP.NET.
You can not simply create instance of the WebForm and expect it to work. You
must initalize it correctly which is ASP.NET job.

What are you trying to achieve?

George.

"Farooq Khan" <fa*********@hotmail.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
attached is the code file. i have cut down all the irrelevant stuff. in
.aspx file i have commented the line of code causing the trouble. let me
know what i'm doing wrong.
in short the Response.Write call is beign made from the code behind class.

Best Regards,
Farooq Khan
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:JB**************@cpmsftngxa06.phx.gbl...
Hi Farooq,

Where is this code in your application? The Reponse object is not
available in some areas.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
From: "Farooq Khan" <fa*********@hotmail.com>
Subject: Response.Write's unusual behavior (i think)
Date: Thu, 23 Oct 2003 21:45:30 +0500
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <u1**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 202.141.251.2
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:186093X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

why does Response.Write in a method of code-beind class when called frominpage code (i.e in <%---%>), after creating object of that class, failswhen called
while it works perfectly ok while calling the same method same way exceptfor creating object instead directly calling the method?
i get this when trying to do that:-

************************************************* *
Response is not available in this context.
Description: An unhandled exception occurred during the execution of thecurrent web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Response is not available inthis context.

Source Error:

Line 32: for (a=1; a<8; a++)
Line 33: {
Line 34: Response.Write("<H"+a.ToString()+">Heading
<H"+a.ToString()+">");
Line 35:
Line 36: }
************************************************* *

i'm new to the .NET stuff and was playing around with it when came acrossabove......let me know if i'm doing something wrong there.
Thanks in advance.

Best Regards,
Farooq Khan


Nov 17 '05 #3
Farooq,

There are a couple of issues here:

1. Don't use inline code like you did in classic ASP. You want to keep
your ASP.NET code in your code-behind.

2. Your code is failing because you are trying to call the Method() method
on a new instance of WebForm2, and that instance does not have a Response
object. You can only access the Response object for the page that is
currently executing.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "Farooq Khan" <fa*********@hotmail.com>
References: <u1**************@TK2MSFTNGP12.phx.gbl> <JB**************@cpmsftngxa06.phx.gbl>Subject: Re: Response.Write's unusual behavior (i think)
Date: Fri, 24 Oct 2003 13:41:33 +0500
Lines: 259
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <uf**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 202.141.251.2
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:186269
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

attached is the code file. i have cut down all the irrelevant stuff. in
.aspx file i have commented the line of code causing the trouble. let me
know what i'm doing wrong.
in short the Response.Write call is beign made from the code behind class.

Best Regards,
Farooq Khan
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:JB**************@cpmsftngxa06.phx.gbl...
Hi Farooq,

Where is this code in your application? The Reponse object is not
available in some areas.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.
--------------------
>From: "Farooq Khan" <fa*********@hotmail.com>
>Subject: Response.Write's unusual behavior (i think)
>Date: Thu, 23 Oct 2003 21:45:30 +0500
>Lines: 36
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <u1**************@TK2MSFTNGP12.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: 202.141.251.2
>Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
>Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.framework.aspnet:186093 >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>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 calling the same method same way except >for creating object instead directly calling the method?
>i get this when trying to do that:-
>
>************************************************* *
>Response is not available in this context.
>Description: An unhandled exception occurred during the execution of the
>current web request. Please review the stack trace for more information
>about the error and where it originated in the code.
>
>Exception Details: System.Web.HttpException: Response is not available in >this context.
>
>Source Error:
>
>Line 32: for (a=1; a<8; a++)
>Line 33: {
>Line 34: Response.Write("<H"+a.ToString()+">Heading
><H"+a.ToString()+">");
>Line 35:
>Line 36: }
>
>
>************************************************* *
>
>i'm new to the .NET stuff and was playing around with it when came across >above......let me know if i'm doing something wrong there.
>Thanks in advance.
>
>Best Regards,
>Farooq Khan
>
>
>



Nov 17 '05 #4

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

Similar topics

6
by: Colin Colin | last post by:
I have an ASP program that is getting an error. When I get the error I get Page Cannot Be Displayed along with the line that causes the error and what the error is. What I am not getting is any...
13
by: TinyTim | last post by:
I'm a newbie at ASP & HTML. It seems that when you use server side code and you're going to return a customized HTML form with several fields and labels, you have to do an extensive amount of...
2
by: Indra Heckenbach | last post by:
I have recently come across an unusual behavior with Postgres 7.3.4 on a Linux RH 9 system. My database has encoding set to "UNICODE", and the table includes Japanese text. I'm trying to issue a...
4
by: etropic | last post by:
Im confused I want an .aspx page to have a table with my data in it. At first I wrote FillTablew(); in my Page_Load even in the Code Behind file. I had it loop the db etc. and use Response.Write...
1
by: Marty McDonald | last post by:
I have a web page. It uses web service (on localhost) to get data. I'm able to get to my web service properly, data is returned. Then, via JavaScript, I HTTP post to another site. Instead of...
12
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug...
4
by: D | last post by:
Hi I'm obviously still learning here but what I've created is a page with a calendar and button. When I click the button I do a number of tasks and would like to output the progress in messages...
4
by: cbtechlists | last post by:
I have an ASP app that we've moved from a Windows 2000 to a Windows 2003 server (sql server 2000 to sql server 2005). The job runs fine on the old servers. Part of the app takes a recordset and...
4
by: rakesh19 | last post by:
Hi, I am dynamically including .js files on a button click. There is a segregated function to do the same. It doesnt seems to work well. If I put a alert tag in the includeJSFile function, it works...
1
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: 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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.