473,499 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page.Request in class file

Why is the request and response properties not available from within a class
file? Do I need to refer in same way to objects or classes from the calling
page?

Thanks,
Colin.
Nov 18 '05 #1
3 1000
They are properties of Page class. You need to refer to an instance of Page
class.

For example:

public class aa
{
private System.Web.UI.Page callingPage;

public aa (System.Web.UI.Page callingPage)
{
this.callingPage = callingPage;
}

public string ff ()
{
return callingPage.Request.Params["par1"].ToString()
}
}
Eliyahu

"Colin (615498)" <@.c> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
Why is the request and response properties not available from within a class file? Do I need to refer in same way to objects or classes from the calling page?

Thanks,
Colin.

Nov 18 '05 #2
Eliyahu Goldin wrote:
They are properties of Page class. You need to refer to an instance
of Page class.

For example:

public class aa
{
private System.Web.UI.Page callingPage;

public aa (System.Web.UI.Page callingPage)
{
this.callingPage = callingPage;
}

public string ff ()
{
return callingPage.Request.Params["par1"].ToString()
}
}
Eliyahu

Or:
You can use System.Web.HttpContext.Current.Request
(and Session, Cache, Response, ..)

But: this will only work if there is really a httpcontext (=called as result of
an http request)

Hans Kesting
"Colin (615498)" <@.c> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
Why is the request and response properties not available from within
a class file? Do I need to refer in same way to objects or classes
from the calling page?

Thanks,
Colin.

Nov 18 '05 #3
Hello Colin (615498),

You can use this:

HttpContext.Current.Request or HttpContext.Current.Response

If you need other methods from the Page class, try this:

Page page = (Page)HttpContext.Current.Handler;

HTH!

--
Matt Berther
http://www.mattberther.com
Why is the request and response properties not available from within a
class file? Do I need to refer in same way to objects or classes
from the calling page?

Thanks,
Colin.


Nov 18 '05 #4

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

Similar topics

5
4907
by: rathnesh | last post by:
when using a web application which includes taking an asp page then going to another asp page and coming back to first page ...some times connection to iis gets terminated and page canot be...
7
4059
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
1
9029
by: jgamble | last post by:
Hi, Here's a question for you all. Under "classic" ASP any ASP page could have any number of #Include files. Using #Include files I could have functions which were common to my whole site and...
5
1809
by: ozie | last post by:
Hi , I am new to ASP.NET. I was reading about Page class in one of the ASP.NET books and am confused with the way the Page class is actually implemented.What is didnt understand in when is this...
4
1421
by: pawel | last post by:
Hi! I have an .aspx page which returns an image. This page takes some GET parameters, so URL looks like this: http://localhost/page.aspx?id=1234 Now, when the user click this link, I want that...
2
3603
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
2
1820
by: Ryan Taylor | last post by:
Hello. I am trying to upload a file and save it in a Sql Server 2000 database. This seems to be working fine. However, when I download the file from SQL Server, it appears that the page that is...
15
4712
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
5
1247
by: pbo.spam | last post by:
I have a little problem. I designed a webpage (VB.Net) with code behind "Page_Load". If the process works fine, the page is shown. If the process raises an exception, I catch it and modify a...
6
4837
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
0
7134
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
7180
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,...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
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
5479
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,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
307
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.