B
Beatrix
Dear All,
I have checked many places but couldn't find the error in this script.
Error is:
"Control 'YourAnswer' of type 'TextBox' must be placed inside a form tag
with runat=server"
Code:
private void Load_Controls()
{
TextBox txtYourAnswer = new TextBox();
txtYourAnswer.ID = "YourAnswer";
txtYourAnswer.Text = "";
Controls.Add(txtYourAnswer);
}
if I add:
HtmlForm f =FindControl("form1");
and change last row to f.Controls.Add(txtYourAnswer);
I get:
Error 1 Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.HtmlControls.HtmlForm'. An explicit conversion exists (are you
missing a cast?) D:\Projects\QuizFolder\Quiz3\Q1.aspx.cs 33 21 D:\...\Quiz3\
Thank you for your help,
I have checked many places but couldn't find the error in this script.
Error is:
"Control 'YourAnswer' of type 'TextBox' must be placed inside a form tag
with runat=server"
Code:
private void Load_Controls()
{
TextBox txtYourAnswer = new TextBox();
txtYourAnswer.ID = "YourAnswer";
txtYourAnswer.Text = "";
Controls.Add(txtYourAnswer);
}
if I add:
HtmlForm f =FindControl("form1");
and change last row to f.Controls.Add(txtYourAnswer);
I get:
Error 1 Cannot implicitly convert type 'System.Web.UI.Control' to
'System.Web.UI.HtmlControls.HtmlForm'. An explicit conversion exists (are you
missing a cast?) D:\Projects\QuizFolder\Quiz3\Q1.aspx.cs 33 21 D:\...\Quiz3\
Thank you for your help,