ASP.NET/C# 2.0 - Getting the page's theme in a class

N

Norman Wooten

Ok, I am a nOOb C#/NET coder, so this is probably easy.. heh heh (only been
pecking is these languages for a week now, just converted from vbscript and
classic asp)

But anyways, I have a class library - and wish to be able to determine the
currently loaded theme for the calling webpage programaticly.. I can do this
in the code-behind using page.theme - but can not in the class library (for
whatever small reason I am missing)..

Hope I am explaining myself clearly :))

But again, I am complete utter nOOb right now.. took me an hour to figure
out how to use a response.write in the class library..
System.Web.HttpContext.Current.Response.Write("Hello World!");
LoL

Well Any Help is Appreciated,
-Norman
 
M

Mark Rae

Ok, I am a nOOb C#/NET coder, so this is probably easy.. heh heh (only
been pecking is these languages for a week now, just converted from
vbscript and classic asp)

But anyways, I have a class library - and wish to be able to determine the
currently loaded theme for the calling webpage programaticly.. I can do
this in the code-behind using page.theme - but can not in the class
library (for whatever small reason I am missing)..

Hope I am explaining myself clearly :))

Why not just pass Page.Theme as a parameter to the method(s) in your class
which need it...?
 
N

Norman Wooten

Ok, finally figuered it out with your help! This what I came up with:

// Using Namespaces
using System.Web;
using System.Web.UI;

// Variable Declaration
private Page Testing = new Page();

// Casting
Testing = (Page)HttpContext.Current.Handler;

// Then Can Access Like
HttpContext.Current.Response.Write(Testing.Theme);

If there is more streamlined way to Declare/cast on one line or something..
lol.. but I am happy with result anyways :))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top