Add textbox in cs file
hi
i copied these codes from "Wrox-Professional Web Parts and Custom Controls with ASP.NET" to my cs.File
protected override void CreateChildControls()
{
base.CreateChildControls();
//LiteralControl=represent html elements,html and other strings in asp.net page that don't requared procesing on the server
LiteralControl lt;
System.Web.UI.WebControls.TextBox txt = new TextBox();
lt = new LiteralControl("<b>Value: ");
this.Controls.Add(lt);
txt.Text = "Hello,world";
txt.ID = "txtInput";
this.Controls.Add(txt);
lt = new LiteralControl("</b>");
this.Controls.Add(txt);
}
but , i saw this error:
Control 'txtInput' of type 'TextBox' must be placed inside a form tag with runat=server
Why?
|