Object reference not set to an instance of an object.
-
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 -
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 locatedpoints 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