UserControl question

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,182
Latest member
BettinaPol

Latest Threads

Top