views:

62

answers:

3

i recently was working on an ASP.NET MVC site that basically serves static html and uses ajax gets to return data to the page when inputs are changed. there is actually no posting or getting from an html input tag on the pages at all. (it is a specific style of site that is not used by the general public, so having compatibility problems for people without javascript is not an issue)

after designing the site, i realised that i hadn't even included any form tags. as the site does not use any direct posts or gets, and apart from it being just good html design, i wondered, in my particular situation, if there was any point to having any form tags on the page?

A: 

As ASP.NET MVC tries to differ from Web Forms, to introduce a new approach in designing web applications. They do not require forms. In fact i think it's better not to be used for navigation, submitting data, etc. Otherwise, there is no use of the MVC pattern if you still do it "the good old ASP.NET" way.

Of course ... I'm sure there are good reason forms to be used in proper places, but not as a general concept in your design.

You can read here: http://msdn.microsoft.com/en-us/magazine/cc337884.aspx how MVC was introduced in the beginning. "ASP.NET MVC - Building Web Apps without Web Forms" by Chris Tavares

anthares
in a typical mvc web app though, wouldn't the form tag be required to know where to post back to?
benpage
ASP.NET MVC doesn't support postback in sence that ASP.NET does. And there is no need to. You can't do a postback as you may have used to do in ASP.NET, but you can respond to event in a control that is part of your form and invoke an action in the event.
anthares
In the terms of MVC it's not very common a page to call to itself. The semantic of a page is to invoke an action and it's strange an action to invoke as a result himself - it's not forbidden of course, but it's different from ASP.NET (where a page would typically take care for itself).
anthares
sorry i think 'post back' was the wrong term. however MVC surely requires a form tag on the page if it is indeed posting to another view to handle updates/inserts/deletes.
benpage
A: 

Retaining a form is useful if you need your application to degrade gracefully if JavaScript is disabled or the likes. Also, jQuery and Prototype have nice Ajax helpers for serializing inputs using a form, which is really nice when you have multiple sets of data that could be submitted to different ajax endpoints from one page.

HackedByChinese
Pertaining to the first part of your answer, the OP stated `having compatibility problems for people without javascript is not an issue`
Baddie
A: 

So I guess the answer to my question is no.

benpage