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
some compiled class which is instantiated on the code-behind page. So
then my question really is, how can the compiled class reference the
Request and Server objects of the page that instantiated the class?
Here's some pseudo code for illustrative purposes....
File = default.aspx.cs
public class _default : System.Web.UI.P age
{
private void Page_Load(objec t sender, System.EventArg s e)
{
try
{
// Instantiate my class ...
classes.c_env C = new classes.c_env() ;
Response.Write( C.pageName);
} catch (Exception e) {
Response.Write( e.Message);
}
}
File = /Classes/c_env.cs
public class c_env
{
private string pagename;
// Constructor
public c_env()
{
this.pagename = "";
}
// Properties
public string pageName
{
get
{
return Request.ServerV ariables["SCRIPT_NAM E"].ToString();
}
}
}
How can this separate class access
Request.ServerV ariables["SCRIPT_NAM E"].ToString(); from the
instantiating aspx page?
Thanks
John 1 9055
Import System.Web namespace into the class. Then you can access Context by
using:
HttpContext.Cur rent.Response.W rite("Something ");
HttpContext.Cur rent.Session["key"]="Value";
and so on.
--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy http://www.mansoft.fi
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
Email: jo****@aspallia nce.com
"jg*****@norepl y.screenpages.c om" <jg*****@screen pages.com> kirjoitti
viestissä news:ff******** *************** ***@posting.goo gle.com... 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 some compiled class which is instantiated on the code-behind page. So then my question really is, how can the compiled class reference the Request and Server objects of the page that instantiated the class?
Here's some pseudo code for illustrative purposes....
File = default.aspx.cs
public class _default : System.Web.UI.P age { private void Page_Load(objec t sender, System.EventArg s e) { try { // Instantiate my class ... classes.c_env C = new classes.c_env() ; Response.Write( C.pageName); } catch (Exception e) { Response.Write( e.Message); } } File = /Classes/c_env.cs
public class c_env { private string pagename;
// Constructor public c_env() { this.pagename = ""; }
// Properties public string pageName { get { return Request.ServerV ariables["SCRIPT_NAM E"].ToString(); } } }
How can this separate class access Request.ServerV ariables["SCRIPT_NAM E"].ToString(); from the instantiating aspx page?
Thanks
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Salek Talangi |
last post by:
Hello,
I have following (probably very basic) problem:
I made a html-frameset in VS.net, where the frames
itself are aspx-pages with webforms.
Now I want to access the webforms (eg. give a label a
text) from one .aspx.vb page.
I managed to get all the code into one file by writing
the same file in the codebehind statement of all aspx
files.
Now I have one big .aspx.vb file with:
|
by: Alek Davis |
last post by:
Hi,
Is it possible to access intrinsic ASP objects, such as Request, from a .NET
class. Say, I have a .NET library exposed via a COM or COM+ wrapper. Can
this library retrieve the request info (basically, server variables exposed
via the Request object), when it is invoked from a traditional ASP (not
ASP.NET) application? Any ideas? Thanks in advance.
Alek
|
by: Nathan Sokalski |
last post by:
I would like to access variables and functions that I declare in the
Global.asax.vb file. However, I am having trouble doing that. What does the
declaration have to look like in the Global.asax.vb file, and what would I
do to access it? (I am using VB.NET for my code) Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: Joergen Bech |
last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running
application on a web server outside of my control, but only the first
time I run it:
1. After a long period of inactivity (or updating the code-behind dll)
accessing any aspx page in the application causes the application
to run for the first time. Some of the initialization involves
reading and writing some text and xml files using simple streamreader
and streamwriter...
|
by: Daniel Corbett |
last post by:
I am trying to save a file dynamically created in a webpage. I get the
following headers, but cannot figure out how to save the attachment. I am
basically trying to replicate what internet explorer would do in this case.
The headers I am getting are:
Headers {Content-Disposition: attachment; filename="dynamic_file.mdb"
Connection: close
Cache-Control: private
Content-Type: application/octet-stream
| |
by: Olivier BESSON |
last post by:
Hello,
I have a web service of my own on a server (vb.net). I must declare it with
SoapRpcMethod to be used with JAVA.
This is a simple exemple method of my vb source :
>************************************************************************
> <WebMethod(), System.Web.Services.Protocols.SoapRpcMethod()> _
> Public Function HelloWorld() As
> <System.Xml.Serialization.SoapElementAttribute("return")> String
|
by: sonu |
last post by:
I have following client side code which i have used in my asp.net
project
SummaryFeatured Resources from the
IBM Business Values Solution Center
WHITEPAPER :
CRM Done Right
Improve the likelihood of CRM success from less than 20 percent to 60
percent.
WHITEPAPER :
|
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...
|
by: Greg Scharlemann |
last post by:
There is probably an easy solution to this that I've overlooked
somewhere...
I have a main file, call it main.php, and an include file,
myInclude.php. I'm accessing main.php via:
http://www.example.com/main.php?page=new&var1=test&var2=test2
main.php:
-------------------
<?php
|
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,...
|
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...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |