Adding Controls Programmatically

  • Thread starter Thread starter Chakravarti Mukesh
  • Start date Start date
C

Chakravarti Mukesh

Hi All,
I tried to add controls on page (C#) by using
Page.Controls.Add(ctrl);
it displays me an error

Server Error in '/AgentExtension' Application.
--------------------------------------------------------------------------------

Control 'ctl02' of type 'ImageButton' must be placed inside a form tag with
runat=server.
How this could be done?

Thanks
 
Normally how I do it. You can also simply declare the form in codebehind
and add it to that too.

protected HtmlForm Form1;

Form1.Controls.Add(...);

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top