I am attempting to dynamically add divs on a page through ASP but nothing seems to happen.
The function I created is addMainDivs()
--.aspx.cs code behind
--breakpoint
public partial class _Default : Page
{
protected void addmainDiv(int m)
{
System.Web.UI.HtmlControls.HtmlGenericControl newdivs = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
newdivs.Attributes.Add("class", "maindivs");
for(int i = 0; i<= m; i++)
{
maindivs.Controls.Add(newdivs);
}
}
--breakpoint here
protected void Page_Load(object sender, EventArgs e)
{
addmainDiv(1);
}
}
Here is the aspx code:
<div id = "maindiv">
<asp:PlaceHolder ID ="maindivs" runat="server">
</asp:PlaceHolder>
</div>
The function does not get hit at those breakpoints and this is the default start page for my app. The header and footer are hard coded but the code aboves goes into the body under a parent dive id "maindiv"
AutoEventWireup="true"in the page aspx header