Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2003, 02:41 PM
Authorized User
 
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Check for existence of a session variable

I want to check for the existence of the variable session("MyVariable") on my user control. If it does not exist or is unassigned then I want to query the database and assign Session("MyVariable") to a value. Otherwise, if the variable exists I want to do nothing. Is there way to do this?
In ColdFusion we use ParameterExists() or IsDefined(). is there an equivalent in ASPX?

Thanks
 
Old November 12th, 2003, 05:03 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

All you need to do is this:

If Session.Item("MyVariable") Is Nothing Then
    'assign it here.
End If

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 12th, 2003, 11:09 PM
Authorized User
 
Join Date: Nov 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if u are using c-sharp
you could do as below:
if(Session[""]!=null)
{}
else
{}






Similar Threads
Thread Thread Starter Forum Replies Last Post
Check for existence of a cookie GLKGail Classic ASP Basics 0 June 10th, 2008 10:49 AM
How to check for a valid session? deb1980 ASP.NET 2.0 Basics 8 March 24th, 2007 06:27 PM
how to check variable value gantait XSLT 3 February 20th, 2007 12:17 AM
check whether a particular session exists or not chayanvinayak PHP How-To 1 May 1st, 2006 04:09 PM
How to check database existence? angelran Classic ASP Databases 0 October 30th, 2005 06:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.