Is it possible to check if the client browser has javascript enabled from ASP.NET code?
I was hoping to ideally do this on PreRender of controls, or PageLoad, so that I can change how they look.
Any suggestions, work arounds etc would be much appreciated.
The only way to know it's on the client side using a <noscript></noscript> tag. Besides , request. Browser. JavaScript tells you if the browser supports javascript, not if it's enabled.
On the web browser menu click on the "Edit" and select "Preferences". In the "Preferences" window select the "Security" tab. In the "Security" tab section "Web content" mark the "Enable JavaScript" checkbox. Click on the "Reload the current page" button of the web browser to refresh the page.
JavaScript is a client-side script, meaning the browser processes the code instead of the web server. Client-side scripts are commonly used when we want to validate data before sending it to the web server, adjusting the interface in response to user feedback, and for implementing other advanced features.
You can't do it, without making a subsequent request I'm afraid.
There are explanations that can be found by doing a search on Google most use an AJAX call or a hidden field that gets popluated via some javascript, that won't get run if Javascript is disabled.
If you have to do it then I'd try doing it on the very first request from the client, and save a cookie (or somethign similar), then check the value of the cookie on subsequent requests. This assumes that the user doesn't enable / disable Javascript often. You could also store a value in the session.
I hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With