Skip to main content
Logo

Why is my content in a form?

A question that we get all the time from customers is why is there a form tag around all the content in a page.

The answer is quite simple, for a .NET web server control to process server events such as postbacks, it must post variables from the web page to the server, and it does this using the form tag.

Wrapping the entire content of a page in a form tag can cause problems as you won't be able to insert another form tag for HTML compliance reasons. There are a couple of ways you can work around this limitation.

Publish a non ASPx page

It is possible to publish and render the page as a non .NET page,  ASPx pages are the default. You must be aware that choosing to render the page of anyting other than .NET will cause any web controls used in the page to not work. This approach would however enable you to put any number of form tags in the page that you wish.

Create a .NET web server control

The recommended approach to solve this problem would be to create a web server control that does the action you need. We have included the source code to one of our web server controls that submits a search query to a different URL as an example below: