views:

122

answers:

8

Not sure if this belongs in community wiki...

Can somebody give some general guidelines on how to successfully build an ASP.NET site that isn't dependent on JavaScript? My understanding is that I should build a functional site initially without JavaScript, and use it to enhance the user experience. That is easier said than done... how can I make sure my site works without JavaScript short of disabling JavaScript and trying it? Or is this something that comes with experience?

+1  A: 

If you want to use many of the ASP.NET controls (i.e. the DataGridView), ASP.NET pages are generated with lots of JavaScript in order to handle the events on the controls (i.e. selecting a row in the DataGridView). I think you're going to lose so much of ASP.NET that trying to have ASP.NET work without JavaScript enabled is impractical.

HardCode
That's interesting. So should I have a check on my pages that require JavaScript? Am I limiting myself by doing that, or am I pretty much required to do that with ASP.NET?
Mike C.
+1  A: 

Disabling Javascript is the best way to test how a web site performs with out it. Good news, IE8's developer tools provide a quick and easy way to do just that. Now, having said that, often times the only thing that you can do is put up a message with a noscript tag to the effect that your site requires javascript for best function.

Tom
Is it even practical to attempt to create sites that don't require JavaScript in ASP.NET?
Mike C.
@Mike: It depends on the content of your site. Rich, interactive, Web 2.0 sites cannot do without client side scripting. Plain text informational websites would probably make do, however.
Cerebrus
A: 

If your concern is with JavaScript being disabled in user's browser then you can check for that and handle your site accordingly.

If you do decide to build the site without JavaScript then you will end up building a somewhat static web site. If your need is just to build a static website then you can go on with this approach.

rahul
I guess for me it all boils down to whether it's possible or practical to attempt to build a site in ASP.NET that doesn't require JavaScript to fully function.
Mike C.
A: 

Write everything with basic html forms and css, and then you will know that it works without javascript.

Once you are happy with it, then look at unobtrusive javascript, so you can modify the way the application works when javascript is enabled.

James Black
+1  A: 

Many ASP.NET functionalities & controls won't work when JavaScript has been disabled. Think of LinkButton's onclick event which contains a call to a JavaScript function.

LinkButton is just an example. But there are many other things too.

Kirtan
+1  A: 

Try ASP.NET MVC! sure most of the examples use JavaScript for the AJAX functionality, but it's easy to build a fully functioning site that doesn't use JavaScript.

Since ASP.NET MVC doesn't use server controls with all their embedded JavaScript, it's a great way to build a site with very minimal and lightweight HTML, while still writting your data access and business logic in C#, VB.NET, or any other .NET language.

Dennis Palmer
I am starting to learn MVC now.
Mike C.
In addition, how do you manage your AJAX functionality so it is compatible with people who don't use JavaScript? Is it possible or practical to do?
Mike C.
That would make a good new question or would be worth a search. I try to make a web app work without AJAX first and then add that funtionality. For desktop browsers I count JavaScript as a given and don't worry much about people who don't have it, but mobile browsers are probably a different story. I'm still working out how I'll handle these issues on the apps I'm building now.
Dennis Palmer
A: 

I've built working ASP.Net sites with little or no JavaScript, so it's definitely possible (just a royal pain.) The trick, and this sounds silly, is to use as few <ASP:> type tags as possible. Those all spawn various levels of JavaScript. Regular old-school HTML elements work just fine with no scripting.

So, on the extreme end, you write, say, your form using all plain-vanilla HTML elements, and then you have that form submit point at another page that accepts the form submit and hands it off to your server-side scripting.

To put it another way, pretend that all you get with ASP.NET is a snazzy server-side programming language and you're writing HTML in 1998.

Now, having done this, I can tell you that what this ends up as is a classic ASP webpage with cleaner programming syntax. ;) Most of the features that make ASP.NET "better" than classic ASP hang on JavaScript, so writing a JavaScript-free ASP.NET system is an exercise in shooting oneself in the foot repeatedly.

However, the one thing you should absolutely do is make sure the first page or two do work without JavaScript. Unlike 10 years ago you can safely assume that any browser hitting your page has JavaScript, and unlike about 8 years ago, your visitors probably don't have JavaScript turned off for speed reasons, but they very well might have something like the NoScript plugin for Firefox dialed all the way to 11. So, your first couple of pages need to work well enough to a) tell the new visitor that they need JavaScript, and b) still look and work good enough to make it look like adding your site to the white list is worth it. (In my experience, most people get the first one done, but in such as way as to totally drop the ball on the second. To put it another way - if your super fancy web 2.0 mega site starts looking like craigslist if noScript is fired up, I'm probably not going to bother letting you run scripts on my machine.)

Electrons_Ahoy
A: 

Last time I looked at some stats about this around 1% disable JavaScript, so why spend hours and hours on this when what you should do is show a message telling the user that your site requires javascript.

Use your time to be productive instead of trying to write around perceived limitations.

PQW