473,624 Members | 2,160 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 1011
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.P age callingPage;

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

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

"Colin (615498)" <@.c> wrote in message
news:ev******** ******@tk2msftn gp13.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.P age callingPage;

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

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

Or:
You can use System.Web.Http Context.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******** ******@tk2msftn gp13.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.Cur rent.Request or HttpContext.Cur rent.Response

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

Page page = (Page)HttpConte xt.Current.Hand ler;

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
4914
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 displayed error comes ..this error does'nt comes on a particular page .please help me to solve this problem..
7
4070
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
9046
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 these files had access to the Request, Session and Server objects from the page they were included on. How can this be done under .NET? My understanding is that these functions that were once in #Include files should really be part of
5
1819
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 Page class created ? Is it when the ASPX file is requested for the first time ? Is this executable Page object saved somewhere in the server hard disk space or is it available only in the memory ? I would really like to know more about how all...
4
1428
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 his browser would receive picture with some good looking name, like image1.jpg. How to do this within ASP.NET code ?.. -- Pawe³
2
3617
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
1828
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 downloading this file is being appended to the end of the file. So I am accidently modifiying every file that is placed in the database. What follows is my code for uploading and downloading a file, minus the sql code to insert/retrieve the data...
15
4744
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
5
1269
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 label inside the page (red color, ...) But, the page is not displayed. I only have a blank screen. No error page, no nothing.. just stops.
6
4862
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
0
8236
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8679
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7159
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5563
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1482
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.