473,385 Members | 1,707 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,385 software developers and data experts.

Retrieving Session Data from a Base Page Class

I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.

We've apparently got an object (custom class) that's stored in session for
each user of our app. This object provides information related to the use
and their environment, as well as default data used in the system. One of
these items is a reference to the stylesheet used for that user.

Rather than have each page in the site retrieve the object and process the
stylesheet reference, I was thinking about having all pages inherit from a
base page class that we write, that would automatically pull the object from
session, get the stylesheet reference and embed the <link> tag in the header
of the page.

Is that do able? Is there something else that I should be looking at doing?
Any suggestions?

Thanks, Dave
Nov 19 '05 #1
4 2262
Use HttpContext.Current.Session.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"David Young" <RE******************@yahoo.com> wrote in message
news:ON****************@TK2MSFTNGP09.phx.gbl...
I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.

We've apparently got an object (custom class) that's stored in session for
each user of our app. This object provides information related to the use
and their environment, as well as default data used in the system. One of
these items is a reference to the stylesheet used for that user.

Rather than have each page in the site retrieve the object and process the
stylesheet reference, I was thinking about having all pages inherit from
a
base page class that we write, that would automatically pull the object
from
session, get the stylesheet reference and embed the <link> tag in the
header
of the page.

Is that do able? Is there something else that I should be looking at
doing?
Any suggestions?

Thanks, Dave

Nov 19 '05 #2
Yes, you should be putting anything repetitive in a BasePage class derived
from Page. Thet way the BasePage can be concerned with things like
stylesheets.

I've even implemented asynchronous page handling in my BasePage without
having to modify any code in the derived Pages.

"David Young" wrote:
I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.

We've apparently got an object (custom class) that's stored in session for
each user of our app. This object provides information related to the use
and their environment, as well as default data used in the system. One of
these items is a reference to the stylesheet used for that user.

Rather than have each page in the site retrieve the object and process the
stylesheet reference, I was thinking about having all pages inherit from a
base page class that we write, that would automatically pull the object from
session, get the stylesheet reference and embed the <link> tag in the header
of the page.

Is that do able? Is there something else that I should be looking at doing?
Any suggestions?

Thanks, Dave

Nov 19 '05 #3
Thanks,
Now, I see that there is no way to access the documents stylesheet directly.
So, would I have to override the pre init and write out my <link> tag there?

Dave

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Yes, you should be putting anything repetitive in a BasePage class derived
from Page. Thet way the BasePage can be concerned with things like
stylesheets.

I've even implemented asynchronous page handling in my BasePage without
having to modify any code in the derived Pages.

"David Young" wrote:
I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.

We've apparently got an object (custom class) that's stored in session for each user of our app. This object provides information related to the use and their environment, as well as default data used in the system. One of these items is a reference to the stylesheet used for that user.

Rather than have each page in the site retrieve the object and process the stylesheet reference, I was thinking about having all pages inherit from a base page class that we write, that would automatically pull the object from session, get the stylesheet reference and embed the <link> tag in the header of the page.

Is that do able? Is there something else that I should be looking at doing? Any suggestions?

Thanks, Dave

Nov 19 '05 #4
My situation may be slightly different than yours in that my application has
just one page and I dynamically load user controls based on user input,
security settings, etc.

The first part of my Page.aspx looks something like this;

<%@ Page language="c#" Codebehind="Page.aspx.cs" AutoEventWireup="false"
Inherits="Portal.Page" %>
<HTML>
<HEAD>
<title><%=PageTitle%></title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<%=OutputCss()%>
</HEAD>
....
</HTML>

Where OutputCss is a member of BasePage;

protected string OutputCss()
{
// Generate a bunch of link tags or even <style> elements
// (actually you could return anything that's valid in the <head>)

return aBunchOfLinkTags;
}

"David Young" wrote:
Thanks,
Now, I see that there is no way to access the documents stylesheet directly.
So, would I have to override the pre init and write out my <link> tag there?

Dave

"Brad Quinn" <Br*******@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com...
Yes, you should be putting anything repetitive in a BasePage class derived
from Page. Thet way the BasePage can be concerned with things like
stylesheets.

I've even implemented asynchronous page handling in my BasePage without
having to modify any code in the derived Pages.

"David Young" wrote:
I normally work on WinForms projects, but have been recently thrust into
this arena and had a questions concering access to objects stored in
session.

We've apparently got an object (custom class) that's stored in session for each user of our app. This object provides information related to the use and their environment, as well as default data used in the system. One of these items is a reference to the stylesheet used for that user.

Rather than have each page in the site retrieve the object and process the stylesheet reference, I was thinking about having all pages inherit from a base page class that we write, that would automatically pull the object from session, get the stylesheet reference and embed the <link> tag in the header of the page.

Is that do able? Is there something else that I should be looking at doing? Any suggestions?

Thanks, Dave


Nov 19 '05 #5

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

Similar topics

8
by: Steve | last post by:
Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini...
14
by: Paul Yanzick | last post by:
Hello, I am trying to develop a book tracking application for my capstone in school, and am running into a problem. The application is an ASP.Net application written in C#. The first page you...
2
by: adam | last post by:
Having spent nearly 2 years in win forms land the inevitable request came for me to "do some web pages". So being new to this bit of .net and having had a look around I can't see where the best...
2
by: Boban Dragojlovic | last post by:
I'm building a complex web-based reservations system. Gathering the user's data requires between 8 and 15 pages (depending on which options they are interested in). I use the "Session" object to...
6
by: Charlie | last post by:
Hi: The code to add items to shopping cart is a seperate class file so I don't have to keep repeating it. If I want to be able to access session data in this class, which class should I base it...
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...
6
by: Ian Williamson | last post by:
Greetings, My company has an ASP.NET based enterprise product that is undergoing some changes and I need some community input to help solve a problem. In the current implementation, any given...
3
by: Frank Esser | last post by:
Hi, I created a base class for my project from that all other pages inherit. Within this page in the OnLoad event I set some session object variables. My intention is that first of all the...
3
by: Goran Djuranovic | last post by:
Hi all, Is there a way to retrieve a derived class name inside a subroutine or a function of the base class? I am trying to get some data from the database, based on which derived class is calling...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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$) { } ...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.