Darren Lewis
Darren Lewis

Reputation: 8488

ASP.NET MVC without javascript

We're developing a site initially without javascript for maximum support with the intention of layering js functionality over the top. The problem we have is where a single page has 2 or more pieces of functionality (as an example a screen to capture personal details that includes a postcode lookup for address). With no ability to change the postback on either the complete form submission or a postback to lookup a postcode we end up with a single controller action that does both. This doesn't feel great as we end up with an Index Action doing more than one thing. Given a js enabled client this would be separated out nicely into separate actions.

I was wondering if anyone else has faced this issue of producing a javascript free ASP.MVC site and what pattern you used to overcome Controller Action bloat as we're calling it?

Upvotes: 2

Views: 2812

Answers (2)

eglasius
eglasius

Reputation: 36037

A couple options.

  1. use a separate form for the postcode lookup, then render the same view you already had / with whatever different info. This can't be nested
  2. identify the button used to post the form / similar to this answer: How can I change the action a form submits to based on what button is clicked in ASP.NET MVC?

Upvotes: 2

roryf
roryf

Reputation: 30160

I've done this specific example (postcode lookup) a couple of times recently and made the decision that users with no Javascript just wouldn't get that functionality. They would get the full address form, which I would then hide and replace with postcode and lookup link via Javascript.

Not an answer to your overall question, but perhaps something to think about.

Upvotes: 0

Related Questions