getting value of session variable

I'm trying to display the value of a session variable in a label. I know the session variable exists because in my page load event I redirect the user to a different page if it's value is null. I want to display it's value in a label to test some things, but I keep getting an error whenever I try. 

 

Here is my code:

  Label:

<asp:Label ID="lblSessionTest" runat="server" Text="Label"></asp:Label> 

 

How I'm trying to display it (in my page load event):

 

lblSessionTest.Text = Session("loggedIn");
  
0
mcru
11/21/2008 10:22:05 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

2 Replies
672 Views

Similar Articles

[PageSpeed] 48

mcru:
lblSessionTest.Text = Session("loggedIn");
 

Are you using  C# or VB.NET? I can see you are using the semi colon as the line terminator, in that case your code should look like this

lblSessionTest.Text = Session["loggedIn"].ToString();

Remember to test if the session variable is NULL before using it 

0
jimmy
11/21/2008 10:33:48 PM

 crap. Thanks, I'm also using classic asp and vb script. Got confused. Thanks

0
mcru
11/21/2008 10:41:44 PM
Reply:

Similar Artilces:

How to get session variable value into a static variable
Hi, On page preinit i am adding few session variables. Now i want to retrive these session variable values into my static variables. protected void Page_PreInit(object sender, EventArgs e) {Session.Add("T", "Default"); Session.Add("T1", "Red"); Session.Add("T2", "Blue");   }   i have few static variables which shud contain these vaules.  public string TT; public string TT1; public string TextForeColor =sess = "#FFFFFF";   i want to get T value into TT ... T1 into TT1..and so on &n...

Session Variables (Get values)
Hi, I am storing some variables in Session, Double values, Integers and Strings.Sometimes these values can be null or empty (""). While retrieving these values from session I will declare a variable of its type. Let say for example I want to get a Double value from Session. Dim dblAmount as DoubledblAmount = Session("sessAmount") Here I am getting trouble when value is empty, its giving an errorConversion from string "" to type 'Double' is not valid. How to handle this kind of situations? Let me know your suggestion. Thanks   Hi. Before assigning the value, check if the session...

Getting value out of session variable
 Hi,How to get the value of a session. It is storing the dataset value. I dont know how to transfer that to a variable.   private SearchDotnet.Searchs.UserSearch sSite;  if ((sSite == null))          {             sSite = Session["Site"];           }         }  The thing is sSite is  delcared as above. I need to unload the session variable to sSite. Have not found a...

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

Getting a session variable value in Servlet
Hi, I am using psSession to set and get session variables in PowerDynamo scripts. I also had to use servlets for serving some of the pages. I want to access the session variables I have set in PowerDynamo scripts from my servlet. I tried session.getValue from my servlet. But it returns a null in servlet. Any ideas as to how I can get the values of session variables in my servlet? TIA, Mani. Mani, I would think that because they are two different session types you could not do this. A workaround would be to create a cookie that you can use from either spot Scott ...

Session variable value gets lost
I am using asp.net 3.0 with C#. My web application requires some values that is used across my User Controls. These values are pertaining to the login user name and User type. When each user is logged in I store that username and user type in a session variable and whenever i need to used it like in a query I just called the string variable that is assigned to the Session variable. My problem is sometimes my session object/ string variable loses its value and I am wondering is there another way of storing my User's credential so that the value will not be lost until the User closes his/h...

How to get session variable values in webpart?
Anyone know that how to get session variable values in webpart? I developed a ASP.NET page to accept a input order code e.g. "E923829" and set it as session variable for the following working page. One of the working page is containing a webpart to show this order summary e.g. number of items and total price. I'm using VB.NET to develop this webpart. I'd tried to use Dim OrderNumber as string = Page.session("ORDER_NUMER"). But this will cause error while loading the webpart. Your advice will very appreciated....

Get value of hidden gridview into session variable
 Hello and thanks for any ideas on this in advance.I have a hidden casegridview from a sqldatasource with 2 values (case_id, client_id) The case gridview datasource takes a client id parameter from a second gridview, clientI'm trying to get the case_id into a session variable and can't figure out how to do it.I tried using onselectindexchange for gridview2 but that didn't return anything because gridview2 doesn't have select enabled.I have this code for my client gridview that gets a client id into a session variable: protected Sub GridView1_SelectedIndexChange...

Getting variables from a post or get?
Sorry for the newbie post, but i am from a PHP world. Im now learning ASP.NET.Im having a bit of problem figuring out how to get/post a variable on an input field. All i want to do is, get the value from an input form and display it again on the page. Here's my code.. <form id="form1" runat="server" acceptcharset="utf-8"> Your name: <input id="name" name="name" type="text" /> <asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="Default.aspx" /> </form> All i want is to get the value of name and display it on the page it self. How can i do that...

Can not get the correct value back from session variable.
 When I assign multiple values to a session variables, I can only access the last one.Session(CheckUser.FirstName) = tbFirstName.Text      (John)Session(CheckUser.LastName) = tbLastName.Text     (Smith) The result I get from this is always 'Smith'.Session.Item(oLogin.FirstName) What am I doing wrong? Thanks,Sully1 try like creating an arraylist and store it in session. check this link http://forums.asp.net/t/1317594.aspx"Never underestimate the power of stupid people in large groups" Sully1:Session.Item(oLog...

Getting Value from Client-side InputBox to .net variable
hi, im doing a login page for our timekeeping. Since there's no msgbox available on asp.net, im doing it dynamically via javascript. How do i Get the value frm a dynamically written javascript (such as inputbox) to a .net variable? here's the logic of my program, user logs in hits the button and sub-routine Login will be fired, if user is late -- call Check_Late Sub, this is whre the client-side script was built -- then after that i wanted to be able to get the value from an inputbox. '// if button login clicked Sub Login(Sender As Object, E As EventArgs) .......

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

getting dropdown list value from usercontrol to change session variable
I have a problem, I have a user control that has 2 drop down lists, what I need to do is use the value of the selected item in the dropdown list to use in the selection of data in a datagrid on the main page. Basically I just need to take the values, and be able to plug them in (during a page load event) and use them in the query. Right now the usercontrol gets fired AFTER all of the other things are loaded. I thought that by setting a session to the value of the drpdown list would work, but its not triggering anything because 1, its a post back event, and two the usercontrol is...

How to make a DataListImagesShow.Items collection and get the value = sessions (VB.NET)
Hi. I have a code that put some data in a DataList, what i need now it to make a DataListImagesShow.Items collection, and there make a value = a session-parameter.But how do i do that !? i have look at http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.repeateritem(VS.80).aspx  but cant get it. How do i make a DataListImagesShow.Items collection that can take the tabel (From the db) "DogImageDate" and make tha value = with Session("DID") and how do i call the sub, or writeout the results on my site. My DataList code is:  Public Sub OpenDB() Dim Ob...

Web resources about - getting value of session variable - asp.net.getting-started

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Staley: 'A lot of different variables...been a hard year'
... 41° Navigation Home Giants A's Sharks Warriors Kings 49ers Raiders Quakes Insiders More Tickets Shop Watch Staley: 'A lot of different variables...been ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/30/2015 2:24:36 AM