views:

49

answers:

1

Hello, I'm working on a asp.net mvc2 app. I have been using jquery to do various different things in all of my views. They are work from a regular browser quite well. But I'm trying to figure out a good way to get the functionality working with browsers with javascript disabled (like mobile browsers). Is there a way to define a whole different view for non javascript browsers?

A specific example of what I'm trying to do is, I have a <button> with it's onClick calling a javascript that does $.post() to a controller.

What's a good way to make it, so, it works the way it works right now (doing ajax calls) with regular javascript-enabled browsers and it a also works with javascript-incapable browsers, doing a full postback ?

Thanks

+3  A: 

Hey,

I use the unobtrusive javascript approach; get the app working without JavaScript, then add in extensibility with JQuery so that the app will work when scripts are turned off, or if the JS fails to download.

Same approach I believe that @James Kolpack is talking about. This is the true failsafe approach. While you can detect the support of JS by the browser through Request.Browser, this isn't accurate to most of the possible scenarios.

Brian
Yes, I forgot the label "Unobtrusive JavaScript" - there's a wiki page on it here: http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
James Kolpack