Problem with web user control loaded programatically

J

Jack David

I am loading web user controls into a web page programitically using the
cone below:

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

//Session["ScriptOID"]= "WonderKiss";

Session["ComponentOID"] = "Introduction";

Control c1 = LoadControl("Read_Text_1.ascx");

Page.Controls.Add(c1);

}

The problem is that if the control contains a form control I get an error
message that tells me that the control must be placed between form tags. The
example above is just a test of a single control. In the future I want to be
able to load multiple controls.

Any suggections

Thanks

Jack David

www.telasphere.com
 
J

Jim Cheshire [MSFT]

Jack,

Try using a Placeholder control and adding the control to it. That way you
can control exactly where it goes on the page.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top