Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Object reference not set to an instance of an object wen the cookie has no value

Object reference not set to an instance of an object wen the cookie has no value

Scheduled Pinned Locked Moved ASP.NET
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anbusenthil
    wrote on last edited by
    #1

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load con = New SqlConnection(ConfigurationManager.ConnectionStrings("ESCConnection").ConnectionString) If IsPostBack = False Then gridbind() End If 'for setting language preference If Request.Cookies("lang").Value Is Nothing Then------>(Object reference not set to an instance of an object wen the cookie has no value) Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") 'get the culture info to set the language rm = New ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources")) ci = Thread.CurrentThread.CurrentCulture LoadStrings(ci) End If

    S C 2 Replies Last reply
    0
    • A anbusenthil

      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load con = New SqlConnection(ConfigurationManager.ConnectionStrings("ESCConnection").ConnectionString) If IsPostBack = False Then gridbind() End If 'for setting language preference If Request.Cookies("lang").Value Is Nothing Then------>(Object reference not set to an instance of an object wen the cookie has no value) Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") 'get the culture info to set the language rm = New ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources")) ci = Thread.CurrentThread.CurrentCulture LoadStrings(ci) End If

      S Offline
      S Offline
      suzzain
      wrote on last edited by
      #2

      before retrieving the value from cookie check if ur cookie is not null

      1 Reply Last reply
      0
      • A anbusenthil

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load con = New SqlConnection(ConfigurationManager.ConnectionStrings("ESCConnection").ConnectionString) If IsPostBack = False Then gridbind() End If 'for setting language preference If Request.Cookies("lang").Value Is Nothing Then------>(Object reference not set to an instance of an object wen the cookie has no value) Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US") 'get the culture info to set the language rm = New ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources")) ci = Thread.CurrentThread.CurrentCulture LoadStrings(ci) End If

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        anbusenthil wrote:

        If Request.Cookies("lang").Value

        Check first if the cookie Is Nothing.

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups