I'm trying to create some sort of forum and want to add a new div (with some text in it) every time I click the button. (this will change later on when I get everything from a database) So the idea is; click the button, div appears, click the button again, another div appears, right underneath the last one, repeating infinitely. I got as far as creating 1 div, but it won't make any more. Here's my code:
protected void Button1_Click(object sender, EventArgs e)
{
i += 1;
top += 60;
try
{
Panel div = new Panel();
div.ID = "panel" + i;
div.CssClass = "postdiv";
div.Style["position"] = "absolute";
div.Style["top"] = top.ToString();
form1.Controls.Add(div);
}
catch (Exception er)
{
Console.Write(er);
}
}
I think my problem lies with the div.Style["top"] = top.ToString(); but I'm not sure. Anyone know a solution?