I am getting a NullReferenceException in my code.
I call a method datecheck from another other page in the same project and pass two strings as parameters. These contain the date selected by user in string format. Now when i try to initialize 2 labels label1 and label2 with these string values I get the NullReferenceException.
Code lines showing error and stack trace is as follows:
Line 39: public void datecheck(String s1, String s2)
Line 40: {
Line 41: Label1.Text = s1;
Line 42: Label2.Text = s2;
Line 43: }
Source File: I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking Status.aspx.cs Line: 41
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
GuestHouseApp.Booking_Status.datecheck(String s1, String s2) in I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking Status.aspx.cs:41
GuestHouseApp.Booking.Button1_Click(Object sender, EventArgs e) in I:\Aditya\GuestHouse\GuestHouseApp\GuestHouseApp\Booking.aspx.cs:28
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +113
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5348