Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is enabling JavaScript in browser a MUST to get working ASP.NET pages?

This is a newbie question (I'm sure it is). I have tried for the first time in a little ASP.NET web application I am working on what happens if I disable Javascript in a browser (I'm testing mainly with Firefox).

Result: My application is completely broken, although I didn't ever write any single line of Javascript.

For instance: I have a link button on a page from a LoginStatus control. Looking at the generated HTML code in my browser I see this:

<a id="ctl00_ctl00_LoginStatus" href="javascript:__doPostBack('ctl00$ctl00$LoginStatus$ctl02','')">Login</a>

Similar with some link buttons in a ListView control which allow to sort the list by certain data fields: The href of the generated anchor tag contains this: javascript:WebForm_DoPostBackWithOptions(...).

So clicking on "Login" or trying to sort does not work without having Javascript enabled.

Does this mean: With disabled Javascript in the browser ASP.NET applications won't work properly? Or what do I have to do to get the application working with disabled Javascript?

Thanks for your feedback!

like image 274
Slauma Avatar asked Feb 23 '10 17:02

Slauma


2 Answers

Some stuff will work, some won't (see here). This is not to say you can't use ASP.NET without Javascript, you'll just have to avoid the below mentioned controls (and I'm sure a plethora of 3rd party controls as well).

The ASP.NET server controls that depend on being able to run client script include:

  • The LinkButton and HtmlButton server controls require script. (This is not true for the Button Web server control or the HtmlInputButton or HtmlInputImage controls.)
  • By default, the Calendar control implements month navigation and day selection using LinkButton controls. If you set control properties to allow users to select a day, week, or month, or if you allow users to navigate to other months, then the Calendar control will generate client script. If you use the Calendar control simply to display a single month with no selection or navigation, the control does not require client script.
  • Any Web server control whose AutoPostBack property is set to true; the client script is required so that the control will post the page.
  • The Web validation controls, which require client script to support client-side validation. If the client does not support script, validation will run on the server only.
like image 104
Marek Karbarz Avatar answered Nov 11 '22 12:11

Marek Karbarz


Unless you switch over to the ASP.NET MVC framework, yes, ASP.NET sites built with the web forms model requires JavaScript.

Elements that have autopostback turned on, any linkbutton controls or button controls, and any client-side validation will cease to function, as you've discovered.

like image 43
Tim S. Van Haren Avatar answered Nov 11 '22 11:11

Tim S. Van Haren