ASP.NET, C#
As the title suggests I was wondering if anyone knew how to programatically (c# code behind file) add a div to another a container div (in the aspx page).
Thanks in advance
ASP.NET, C#
As the title suggests I was wondering if anyone knew how to programatically (c# code behind file) add a div to another a container div (in the aspx page).
Thanks in advance
Panel myChildPanel = new Panel();
myContainerPanel.Controls.Add(myChildPanel);
Aside from using a Panel like ocdecio suggested, there are several other possibilities.
It depends a little on the level of control you need. Still, under a most circumstances, a Panel that starts out invisible would be best:
<div>
<asp:Panel Visible="false" id="MyPanel" runat="server">
</asp:Panel>
</div>
Then change the visibility from your codebehind when needed.
One cases where you might want to use one of the other methods is when you're stuck with some CSS file that assigns styles based on ID. In that case, using .NET controls is not really an option. But really, you should smack your designer over the head and tell him to use class names instead.