<form id="form1" runat="server">
alert("Please enter the name");
Note:- The form attribute must contain runat="server" attribute.
So this is the way to avoid The Controls collection cannot be modified because the control contains code blocks (i.e. <% … %>) error.