In ASP.NET, Forms have a much greater significance than the forms of HTML. Forms is one of the two ways a Web application is developed using ASP.NET, the other being MVC. The ASP.NET form will include the runat=”server” attribute and only one such form is permitted per page.
Server controls to be executed by the server are always enclosed in ASP.NET forms. Unlike HTML forms, there is no action attribute that specifies the script to be executed on submitting the completed form. Instead, the form posts to itself.
ASP.NET pages are even called “web forms” and this gives an indication of the importance of forms in this platform. These web forms have some characteristics that make them better. For example, we look at the issue of maintaining ViewState.
Usually, when you submit data through a form, and the server detects invalid data, you have to enter all the data again because the data you entered previously would all have been cleared. This can be a big bother if the form contains a lot of data, and the user might even decide to give up, meaning that you lose the chance to get valuable feedback from the user.
In ASP.NET the page you submitted to the server is maintained as is. When you click on the Submit button, the values in the form boxes do not suddenly disappear. If some error had occurred and the server sends and invalid message, you can correct the wrong entries. There will be no need to complete the entire form again.
If you have ever completed a long form online, and had to re-enter the values because of some error, you will appreciate the superior convenience this feature provides!
In ASP.NET forms, maintaining ViewState is the default. You will have to change this default through code if you want the data to be cleared when the form is submitted.