W
Will
I have an aspx page, with an ascx user control on it and
that ascx file has a code-behind page.
I have an event handler for a submit button in the code
behind and I want to check the text field of a textbox
which is in the ascx user control.
for some reason I keep getting the error:
System.NullReferenceException: Object reference not set to
an instance of an object.
here's a snippet:
public TextBox TBName;
Page s = ((Page)HttpContext.Current.Handler);
UserControl u = ((UserControl)s.FindControl("UCName"));
TBName = ((TextBox)ddd.FindControl("TBName"));
TBName.Text = "hello";
I get the error on that last line.. I don't understand
why it says the reference is not set to an instance.. the
TextBox object TBName exists in my ascx file, I declare it
in my code behind as well.
that ascx file has a code-behind page.
I have an event handler for a submit button in the code
behind and I want to check the text field of a textbox
which is in the ascx user control.
for some reason I keep getting the error:
System.NullReferenceException: Object reference not set to
an instance of an object.
here's a snippet:
public TextBox TBName;
Page s = ((Page)HttpContext.Current.Handler);
UserControl u = ((UserControl)s.FindControl("UCName"));
TBName = ((TextBox)ddd.FindControl("TBName"));
TBName.Text = "hello";
I get the error on that last line.. I don't understand
why it says the reference is not set to an instance.. the
TextBox object TBName exists in my ascx file, I declare it
in my code behind as well.