Object reference not set to an instance of an object.

Sep 19 2003 3:05 PM
Hi, In ASP.Net, (code behind C#) from a aspx page i am calling a function of different class(aspx page). In that function i have set a TextBox Text property -> tb.Text="Something" (TextBox is already there..no issues). public void UpdateChatBox() { //tb= new System.Web.UI.WebControls.TextBox(); tb.Text="Something"; } If I call this function from the same page it works fine, as i have mentioned its refernce in the class. protected System.Web.UI.WebControls.TextBox tb; But when I call the same function from another asx page (class); the line tb.Text="Something"; gives the famous error-> Object reference not set to an instance of an object. Adding tb= new System.Web.UI.WebControls.TextBox(); doesn't olve the problem. Can somebody please help. Thanx in advance.

Answers (2)