Wrox Programmer Forums
|
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 September 3rd, 2003, 09:22 PM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help!About Cookies

I have a class,I want to read the cookies with the class code,The class haven't the aspx pages.
The class code like this:

class HDLab
    dim membername

    public sub new()
        if not (context.Request.Cookies("HDLab") is nothing) then
           membername=context.request.cookies("HDLab")("membe rname")
        end if
    end sub
end class

when I run the code,It's have this errors:
System.NullReferenceException

 
Old September 4th, 2003, 08:19 AM
Authorized User
 
Join Date: Jul 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

'Nothing' is not the same as 'DBNull'. Try changing your if statement to this:

if not (context.Request.Cookies("HDLab") is System.DBNull.Value) then...

If you are using code behind you also have to add 'Imports System.DBNull' to the top of your code.

 
Old September 9th, 2003, 08:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:Originally posted by CraigJones
 'Nothing' is not the same as 'DBNull'. Try changing your if statement to this:

if not (context.Request.Cookies("HDLab") is System.DBNull.Value) then...

If you are using code behind you also have to add 'Imports System.DBNull' to the top of your code.

Even if you call its full path, "System.DBNull", you still have to import it?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cookies hastikeyvan Classic ASP Professional 5 May 29th, 2006 07:36 AM
Should I use cookies?? Help Tee88 Classic ASP Basics 3 January 21st, 2005 12:33 AM
Cookies shabboleth Beginning PHP 3 December 30th, 2003 10:32 AM
Cookies cjo ASP.NET 1.0 and 1.1 Basics 1 November 8th, 2003 02:38 PM





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