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

variables between pages

Hi, I am new to asp.net, and here is my question:

when a user logged into a web site, then I will pull his/her name (for example)
from database, then not matter which page he/she viewed, alwasy has his/her name
displayed somewhere at those pages? Some demo code?

Thanks in advance.

ASP.NET Rookie.
Nov 18 '05 #1
1 785
Jason, the long answer to your question is:
There are 5 common state mechanism in ASP.Net which mostly vary in terms of
lifetime and scope (with some exceptions). All are very useful when used at
the right time, they are:

Application - global to all users, exist for the lifetime of the application
Cache - global to all users, exists for the lifetime of the cache duration
Session - specific to each user, exist for the lifetime of the session
timeout
Viewstate - specific to each request, exists for the lifetime of a request
and its postback
Context - specific to each request, exists for the lifetime of the request.

What you want is a sessision (or something which shares its properties such
as a cookie) because (a) the information displayed is specific to each user
(b) the lifetime of the information is as long as the user visits the site.

Here's a very basic example:

Page1.aspx -->
<script runat="server" language="vb">
Sub Page_Load
Session.Add("Name", "Jason")
End Sub
</script>

<a href="page2.aspx">page 2</a>
Page2.aspx -->
<script runat="server" language="vb">
Sub Page_Load
name.Text = cstr(session("Name"))
End Sub
</script>

<asp:literal id="name" runat="server" />
"Jason" <ja***@hotmail.com> wrote in message
news:35********************************@4ax.com...
Hi, I am new to asp.net, and here is my question:

when a user logged into a web site, then I will pull his/her name (for example) from database, then not matter which page he/she viewed, alwasy has his/her name displayed somewhere at those pages? Some demo code?

Thanks in advance.

ASP.NET Rookie.

Nov 18 '05 #2

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

Similar topics

5
by: Larry Woods | last post by:
I am losing Session variables, but only those that are set in the page previous to a redirect to a secure page. Anyone seen ANY situation where Session variables just "disappear?" Note that...
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...
0
by: Van Steenbergen Jan | last post by:
We have a asp.net application that holds data in session variables(items). The admin page of the application has a iframe. In this iframe we load different pages(.aspx) . The pages resides in the...
17
by: Davíð Þórisson | last post by:
now in my web I have some global variables to be used in many different subpages, in the old ASP I simply loaded a variables.asp file into memory using the eval() function. Now I'd like to use XML...
6
by: Roman | last post by:
Which is better when passing values between forms?
1
by: ChrisN | last post by:
Hi there, Two questions related to each other. 1. Session variables expire by defualt when not used for 20 minutes. Does "used" mean that a user has not access any session varibles in 20...
6
by: Kenneth Keeley | last post by:
Hi, I have a Masterpage that controls the basic layout of the pages displayed on a web site. The masterpage also uses some variables. I would like to be able to access some of these variables from...
14
by: Coleen | last post by:
Hi All :-) We have an APSX application using VB.net as the code behind, which uses one or two session variables per page. These Session variables are passed to the final page and calculations...
10
by: EOZyo | last post by:
Hi, i'm trying to set pagination for a search i run on my website, i'll try to explain the easiest i can: When i click the search button on search.php, data is received and stored in variables...
8
by: e_matthes | last post by:
Hello, I keep reading that $_SERVER can easily be faked. Is that true of all server variables, or just some of them? In particular, I'm wondering if server_port can be faked. I'm interested...
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$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.