473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Accessing Page Object from class

Hello there,

I need to be able to call the System.Web.UI.Page 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.Current object?

My class creates custom scripts that it then adds to the page using
Page.ClientScript.IsStartupScriptRegistered and
Page.ClientScript.RegisterStartupScript functions.

Thanks in advance,
Chris
Jul 12 '07 #1
2 12379
Dim p As Page = CType(System.Web.HttpContext.Current.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**************@TK2MSFTNGP03.phx.gbl...
Hello there,

I need to be able to call the System.Web.UI.Page 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.Current object?

My class creates custom scripts that it then adds to the page using
Page.ClientScript.IsStartupScriptRegistered and
Page.ClientScript.RegisterStartupScript functions.

Thanks in advance,
Chris


Jul 12 '07 #2
This worked great.

The C# version is:

System.Web.UI.Page currentPage;

currentPage = (System.Web.UI.Page)System.Web.HttpContext.Current .Handler;
Thanks Teemu!
Chris
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:ej**************@TK2MSFTNGP03.phx.gbl...
Dim p As Page = CType(System.Web.HttpContext.Current.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**************@TK2MSFTNGP03.phx.gbl...
>Hello there,

I need to be able to call the System.Web.UI.Page 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.Current object?

My class creates custom scripts that it then adds to the page using
Page.ClientScript.IsStartupScriptRegistered and
Page.ClientScript.RegisterStartupScript 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
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...
4
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...
13
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...
1
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...
19
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...
1
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...
5
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...
15
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: ...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...

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.