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

  • Thread starter Thread starter Norman Wooten
  • Start date Start date
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
 
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...?
 
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 :))
 
Back
Top