Yes, I see. I just hoped that there is something like a design time attribute for this, but it isn't.
I found that the requirement of the form is made by calling the Page.VerifyRenderingInServerForm(control) method. This method is called only from some form controls (Button, DropDownLis, FileUpload, CheckBox, ImageButton, LinkButton, ListBox, Login, LoginStatus, TextBox), and of course controls that are compound of these. There is a lot of built-in controls, that don't need a form, for example data sources (EntityDataSource etc.) or Content + ContentPlaceholder etc.
What I found interesting is, that VS behaves this way only in the design view. If I drag controls into the source view, then no server form is created.
Finally I will be probably using the adaptive rendering. Something like this:
<browsers>
<browser refID="Default">
<controlAdapters markupTextWriterType="System.Web.UI.HtmlTextWriter">
<adapter
controlType="System.Web.UI.HtmlControls.HtmlForm"
adapterType="FormAdapter"
/>
</controlAdapters>
</browser>
</browsers> using System.Web.UI.Adapters;
public class FormAdapter : ControlAdapter
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
foreach (System.Web.UI.Control c in Control.Controls)
{
c.RenderControl(writer);
}
}
}