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. General Programming
  3. C#
  4. Object reference not set to an instance of an object.

Object reference not set to an instance of an object.

Scheduled Pinned Locked Moved C#
help
2 Posts 2 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.
  • C Offline
    C Offline
    ckruger
    wrote on last edited by
    #1

    If I call it like this within the same class it works fine... private void Page_Load(object sender, System.EventArgs e) { tb1.Text = "text 1"; dtStartDate.Value = "11 Dec 2005"; **GetDate();** } **public void GetDate() { test_string = dtStartDate.Value; }** But if I call GetDate() from another Web Form **( NOT THE test class)**it gives an error ... see code: test t = new test(); **t.GetDate();** test is the class where the GetDate function is located

    I 1 Reply Last reply
    0
    • C ckruger

      If I call it like this within the same class it works fine... private void Page_Load(object sender, System.EventArgs e) { tb1.Text = "text 1"; dtStartDate.Value = "11 Dec 2005"; **GetDate();** } **public void GetDate() { test_string = dtStartDate.Value; }** But if I call GetDate() from another Web Form **( NOT THE test class)**it gives an error ... see code: test t = new test(); **t.GetDate();** test is the class where the GetDate function is located

      I Offline
      I Offline
      imsathy
      wrote on last edited by
      #2

      points to be noted... 1) u have set the values in the page load event of one form and tryin to access the value from another class. it wont work. may be pass the values to the test class constructor. 2) when ur calling the function which returns its textbox value from another class it hasnt been set to a value... 3) its works in ur currnet form bcoz the text box gets the value from the page load event sathy

      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