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
>
>
>