I
Igor Belagorudsky
Hi,
i am trying to analyze data submitted in a form but the problem is that when
i try to create the controls in code (which is what i want to do), it throws
an obect not found exception on postback when i try to Page.FindControl:
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack)
{
Debug.WriteLine(((WebControl)Page.FindControl("testBox_1")).Attributes["hell
o"]);
}
else
{
TextBox txt = new TextBox();
txt.ID = "testBox_1";
txt.Attributes.Add("hello", "hi");
Page.FindControl("test").Controls.Add(txt);
}
}
where control "test" is the form that i am submitting and all im trying to
do is to debug.writeline "hi" on postback.
on the other hand, if i manually put a text box in the aspx page and give it
a hello=hi attribute, everything works like it should.
can someone please tell me what the problem is?
thanks,
igor
i am trying to analyze data submitted in a form but the problem is that when
i try to create the controls in code (which is what i want to do), it throws
an obect not found exception on postback when i try to Page.FindControl:
private void Page_Load(object sender, System.EventArgs e)
{
if (Page.IsPostBack)
{
Debug.WriteLine(((WebControl)Page.FindControl("testBox_1")).Attributes["hell
o"]);
}
else
{
TextBox txt = new TextBox();
txt.ID = "testBox_1";
txt.Attributes.Add("hello", "hi");
Page.FindControl("test").Controls.Add(txt);
}
}
where control "test" is the form that i am submitting and all im trying to
do is to debug.writeline "hi" on postback.
on the other hand, if i manually put a text box in the aspx page and give it
a hello=hi attribute, everything works like it should.
can someone please tell me what the problem is?
thanks,
igor