473,796 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing Page Object from class

Hello there,

I need to be able to call the System.Web.UI.P age object inside a custom
class without actually passing the Page object as an argument. Is there an
alternate way to access the page object from within a class? Something like
the HttpContext.Cur rent object?

My class creates custom scripts that it then adds to the page using
Page.ClientScri pt.IsStartupScr iptRegistered and
Page.ClientScri pt.RegisterStar tupScript functions.

Thanks in advance,
Chris
Jul 12 '07 #1
2 12393
Dim p As Page = CType(System.We b.HttpContext.C urrent.Handler, Page)
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Chris Newald" <cn*****@cars-council.cawrote in message
news:eC******** ******@TK2MSFTN GP03.phx.gbl...
Hello there,

I need to be able to call the System.Web.UI.P age object inside a custom
class without actually passing the Page object as an argument. Is there
an alternate way to access the page object from within a class? Something
like the HttpContext.Cur rent object?

My class creates custom scripts that it then adds to the page using
Page.ClientScri pt.IsStartupScr iptRegistered and
Page.ClientScri pt.RegisterStar tupScript functions.

Thanks in advance,
Chris


Jul 12 '07 #2
This worked great.

The C# version is:

System.Web.UI.P age currentPage;

currentPage = (System.Web.UI. Page)System.Web .HttpContext.Cu rrent.Handler;
Thanks Teemu!
Chris
"Teemu Keiski" <jo****@aspalli ance.comwrote in message
news:ej******** ******@TK2MSFTN GP03.phx.gbl...
Dim p As Page = CType(System.We b.HttpContext.C urrent.Handler, Page)
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Chris Newald" <cn*****@cars-council.cawrote in message
news:eC******** ******@TK2MSFTN GP03.phx.gbl...
>Hello there,

I need to be able to call the System.Web.UI.P age object inside a custom
class without actually passing the Page object as an argument. Is there
an alternate way to access the page object from within a class?
Something like the HttpContext.Cur rent object?

My class creates custom scripts that it then adds to the page using
Page.ClientScr ipt.IsStartupSc riptRegistered and
Page.ClientScr ipt.RegisterSta rtupScript functions.

Thanks in advance,
Chris



Jul 12 '07 #3

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

Similar topics

2
1869
by: Vyas Bharghava | last post by:
Hi all, I have written a server-side component that renders some charts as images. I want to give the charting classes (Pie, Bar etc.) the ability to render themselves onto any active page object. I envisage my users calling my component from Aspx pages like: Pie pie = new Pie(configXml); Pie.Render(this);
4
2805
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than one runat=server form on a asp.net page. However, I still want developers to be able to use asp.net controls to create some apps that are created on the page. So I need multiple forms on a asp.net page(doesn't everyone). I purchased the...
13
2223
by: Bijoy Naick | last post by:
My project contains multiple aspx pages. Many of these pages have code-behind that use several helper functions. Instead of copying each helper function into each aspx page, I am thinking of using a VB Class file to store these. Questions - - How would I "include" this class in each aspx page?
1
3639
by: Axel Dahmen | last post by:
Hi, I've added a property to my Page base class (this base class inherits from Page and all my aspx.cs classes inherit from my base class). This property of mine uses the Session object to determine its return information. After implementing this property, whenever I now open any aspx page in the Visual Studio 7.0 IDE, the following error shows up: "The file failed to load in the Web form designer. Please correct the
19
3591
by: Mark Rae | last post by:
Hi, Is it possible to have programmatic access to the Page object in Application_BeginRequest, or is it too early in the lifecycle...? E.g. to be able to change a page's MasterPage dynamically, something like: protected void Application_BeginRequest(Object sender, EventArgs e) { if (Session == "True")
1
2345
by: Chris | last post by:
I have a class library which sits in a dll and adds controls to a aspx page which calls it. I have been passing it the page object. Is there any way I can reference the page from within the class with out passing it the page object. Its an extra line of code I could do without.
5
1400
by: feli.hp | last post by:
Hello all, Imaybe someone can help me with this question. Is there a direct way of accessing an object instance, if all I know is the value of one of its attributes? The object is part of a list of objects, and I would like to pick the object directly by using this attribute value, instead of going through the list and checking if each objects attribute value is the one I am looking for.
15
1865
by: TonyV | last post by:
Hey all, for debugging purposes, I'd like to be able to access an object's instance name from within the object class. For example, I'd like to be able to do something like this: ------------------------------------------------------------ function FooClass() { // definition of FooClass members } FooClass.prototype.Debug = function() {
1
1509
by: nsphelt | last post by:
I am wondering if it is possible to access the underlying property of a base class within a derived that has overridden that property. I am using VB.NET and when I use the MyBase keyword to access the property of the base class, it accesses the overridden property instead. Specifically, my class is inheriting the TextBox class and I am overriding the Text property to have it display something different based on the state of my class. I was...
0
9685
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
9535
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,...
1
10201
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
9061
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...
1
7558
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5454
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...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
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
3
2931
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.