WebControl implemented as nested in UserControl or Page class

G

Guest

The code

public partial class _Default : System.Web.UI.Page
{
public class PHolder : PlaceHolder
{
}
protected void Page_Load(object sender, EventArgs e)
{
}
}

How can i add nested control PHolder into aspx or ascx.
I don't want to add control to controls collection in codebehind.

Is there any way to use some tag in ascx?

Thanks,
Alexey
 
D

Daniel Fisher\(lennybacon\)

public partial class _Default : System.Web.UI.Page
{
private PlaceHolder PHolder = new PlaceHolder();

Override OnInit(...)
{
PHolder.Controls.Add(new LiteralControl("some other Control"));
}

protected void Page_Load(object sender, EventArgs e)
{
}
}
 
G

Guest

I know this way, but:
"I don't want to add control to controls collection in codebehind.
Is there any way to use some tag in ascx?"
 

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

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top