![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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, |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Thankyou that worked. Can U please explain, why textbox is not working like label? What is the meaning of this mess with htmlform and findcontrol? If I put all my controls in this htmlform, like radiobuttons, etc it will always work? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |