Can any body fix this problem plz.. it throws exception "Object reference not set to an instance of an object"

namespace MC.Master.App1
{
    public partial class EventChecker : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {



        }
       
        protected void Page_Init(object sender, EventArgs e)
        {
            
            Label FeedbackLabel = new Label();
            TextBox InputTextBox = new TextBox();
            Button SubmitButton = new Button();
           
            FeedbackLabel.ID = "FeedbackLabel";
            FeedbackLabel.Text = "Please type your name: ";
            SubmitButton.ID = "SubmitButton";
            SubmitButton.Text = "Submit";
            InputTextBox.ID = "InputTextBox";
           
            SubmitButton.Click += new System.EventHandler(SubmitButton_Click);
          
            Panel1.Controls.Add(FeedbackLabel);
            Panel1.Controls.Add(InputTextBox);
            Panel1.Controls.Add(SubmitButton);
        }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
           
            Button SubmitButton = (Button)sender;
           
            SubmitButton.Text = "Submit again!";
           
            Label FeedbackLabel = (Label)FindControl("FeedbackLabel");
            TextBox InputTextBox = (TextBox)FindControl("InputTextBox");
           
            FeedbackLabel.Text = string.Format("Hi, {0}", InputTextBox.Text);//it throws in this line
        }
    }
}

So inputtextbox or feedbacklable or both is null ? Other controls are fine?

I would have suggested to try create controls in preinit event, however if other controls are being created successfully...

So inputtextbox or feedbacklable or both is null ? Other controls are fine?

I would have suggested to try create controls in preinit event, however if other controls are being created successfully...

feedbacklabel is already filled..InputTextBox user have to fill.. and i cant use preinit because im using a master page...inputtextbox pass a null value.. how to privent that..

Hellooooooooooooooooooooooooooo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.