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
}
}
}