B
Bsiang Tan
Dear all experts,
I wish to create control like ASP TextBox, Label on the fly. I try
search MSDN, it point me the following code :
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void CreateChildControls()
{
// Add a LiteralControl to the current ControlCollection.
this.Controls.Add(new LiteralControl("<h3>Value: "));
// Create a text box control, set the default Text property,
// and add it to the ControlCollection.
TextBox box = new TextBox();
box.Text = "0";
this.Controls.Add(box);
this.Controls.Add(new LiteralControl("</h3>"));
}
But when I compile and excute the page, it give me error :
Control '_ctl0' of type 'TextBox' must be placed inside a form tag with
runat=server.
Is it I miss something out there ? Can anyone please point me the right way
?
I know the easiest way is to create a place holder and put the control in
dynamically, but how can I set the control position if I do it in place
holder ?
A million thank to you all.
Best regard,
Bsiang
I wish to create control like ASP TextBox, Label on the fly. I try
search MSDN, it point me the following code :
[System.Security.Permissions.PermissionSet(System.Security.Permissions.Secur
ityAction.Demand, Name="FullTrust")]
protected override void CreateChildControls()
{
// Add a LiteralControl to the current ControlCollection.
this.Controls.Add(new LiteralControl("<h3>Value: "));
// Create a text box control, set the default Text property,
// and add it to the ControlCollection.
TextBox box = new TextBox();
box.Text = "0";
this.Controls.Add(box);
this.Controls.Add(new LiteralControl("</h3>"));
}
But when I compile and excute the page, it give me error :
Control '_ctl0' of type 'TextBox' must be placed inside a form tag with
runat=server.
Is it I miss something out there ? Can anyone please point me the right way
?
I know the easiest way is to create a place holder and put the control in
dynamically, but how can I set the control position if I do it in place
holder ?
A million thank to you all.
Best regard,
Bsiang