How to use ASP .NET without Javascript?

In ASP.NET, we are used to drag/drop server controls and quickly finish the task, though we do not concentrate much on how they work. The problem arises when JavaScript is disabled in the user's browser, as some of these controls do not work.

Also, if you have rich AJAX features in your site, they will fail miserably if JavaScript is disabled in the browser. Ideally, your client expects the site to work even when JS is disabled in the browser.

Here are some of the ASP.NET server controls which which depend on client script for their functionality:

  • The LinkButton and HtmlButton server controls require JavaScript. (However, the Button Web server control, the HtmlInputButton or HtmlInputImage controls work fine.)

  • Any Web server control whose AutoPostBack property is set to true need client script so that the control will post the page to the server.

  • The Validation controls require client script to support client-side validation. If the client does not support script, validation will run on the server only.

  • Gridview pagination, sorting will not work. Custom pagination has to be used
How to detect if JavaScript is enabled in the browser or not? Check this excellent article at Boutell.com.

So, for the site to still work without JavaScript, use <noscript></noscript> tag, place server side buttons inside the tags and write your server side code in the button click events. These tags will be visible only when JavaScript is disabled. So you will not face any issues when JS is enabled.

An irritating scenario: You need a link button to do a server side task, but it doesn't wont work without javascript.

Work around: Apply styles to server side button and make it look like link button :p
Here is the CSS code you have to write (works fine in all major browsers):

.NewLinkButton
{
background-color:Transparent;
border-style: none;
color:Navy;
cursor: pointer;
display:inline-block;
font-style:normal;
text-align: left;
text-decoration:underline;
}

Please check the MSDN article: ASP.NET Web Server Controls that Use Client Script for more valuable info.

jQuery for absolute beginners.

I have given a KT (Knowledge Transfer) session on jQuery for my colleagues today. Instead of routine power point stuff, I made a jQuery based web page for presenting the content.

My friend and guru @ office, Mr.Praveen Reddy, guided me and shared really good demos, which are apt for beginners.

Here is the presentation.