title: Dynamic Div creation asp.net
body: <p>I am trying to create Div dynamically on the press of button click.</p>
  
  <p>For that i refered this link>> <a href="http://forums.asp.net/t/1349244.aspx">http://forums.asp.net/t/1349244.aspx</a></p>
  
  <p>and made code on server side(.cs page) as follows>></p>
  
  <pre><code>public static int i = 0;
      protected void Button1_Click(object sender, EventArgs e)
      {
          i++;
          HtmlGenericControl newControl = new HtmlGenericControl("div");
  
          newControl.ID = "NEWControl"+i;
          newControl.InnerHtml = "This is a dynamically created HTML server control.";
  
          PlaceHolder1.Controls.Add(newControl);
      }
  </code></pre>
  
  <p>This code was giving me just one div each time when i press the button., I wanted to have addition of divs.</p>
  
  <p>On client side using javascript also i tried>></p>
  
  <pre><code>&lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
  
          &lt;asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" OnClientClick="addDiv();" /&gt;
  
      &lt;/div&gt;
      &lt;asp:PlaceHolder ID="PlaceHolder1" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;script type="text/javascript"&gt;
      function addDiv() {
          alert("Control comming in function");
          var r = document.createElement('Div');
          r.style.height = "20px";
          r.style.width = "25px";
          r.appendChild("div");
          alert("Control going out of function");
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Both of these didnt work.</p>
  
  <p>What mistake am i making?</p>
  
  <p>Is there any thing wrong?</p>