473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adding Controls Programmatically

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
Jan 10 '06 #1
2 1355
Try placing a placeholder control on the page and adding your controls to
that.

MattC
"Chakravarti Mukesh" <cm*****@sparshindia.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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

Jan 10 '06 #2
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

--
MY ASP.Net tutorials
http://www.openmymind.net/
"MattC" <m@m.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Try placing a placeholder control on the page and adding your controls to
that.

MattC
"Chakravarti Mukesh" <cm*****@sparshindia.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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



Jan 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Big D | last post by:
Hi all, I'm having a problem adding controls to a panel dynamically. I have a usercontrol that I create and try to add 5 times to the panel, but I only ever see the first control. I know it's...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
0
by: mark.norgate | last post by:
Righto, a problem with programmatically created controls. Well, in that kind of area anyway. I'm creating and adding controls to my page using TemplateControl.LoadControl quite successfully, but...
2
by: johnb41 | last post by:
I want to create a textbox programmatically and add the SAME textbox to to different panels. This code does not work: Dim tb As New TextBox tb.text = "xyz" Panel1.Controls.Add(tb)...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
4
by: alun65 | last post by:
I'm attempting to programmatically build up some HTML in the code behind. Like so: // Create Hyperlink HyperLink link = new HyperLink(); link.NavigateUrl = "nice cat"; link.Text = "Cats...
6
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.