Checking for Javascript availability/support from ASP.NET 2.0

The other day I had to check whether clients have disabled javascript functionality on their browsers. There is no easy way in ASP.NET 2.0 to acheive that. I also searched the whole of MSDN but only found that .NET 2.0 has a built in HttpBrowserCapabilities class which only can tell whether the client’s browser has support for javascript or not. Later, I discovered that there is a simple and robust way of checking whether the client has disabled javsascript and redirect them to a meaningful error page which can list steps to re-enable javascript functionality specific to their browser.

Here is the code: (placed inbetween <body></body> tags).

<noscript><meta http-equiv=”Refresh” content=”0; URL=../Errors/BrowserError.aspx”/> </noscript>

ASP.NET 2.0 compiler will throw this error:

Cannot switch views: Validation (XHTML 1.0 Transitional): Element ‘meta’ cannot be nested within element ‘noscript’.

But, from what I have seen is it is perfectly ok to ignore this error.

Tip: If you have a master page that has several content pages, the clever approach is to put the code in .master page. Also, the error page can be a .htm file.

5 Responses to “Checking for Javascript availability/support from ASP.NET 2.0”

  1. Very good solution

  2. Thanks a ton for taking time to post “Checking for Javascript availability/support from ASP.
    NET 2.0 Exploring Microsoft.NET & Apple Macintosh”.
    Thank you once again ,Luke

  3. Thanks for finally writing about >Checking for Javascript availability/support from ASP.
    NET 2.0 | Exploring Microsoft.NET & Apple Macintosh <Loved it!

  4. Hurrah, that’s what I was looking for, what a material!

    present here at this web site, thanks admin of this site.

  5. After looking at a few of the blog articles on your blog, I honestly appreciate your way of blogging.
    I saved it to my bookmark webpage list and will
    be checking back in the near future. Take a look at my web site as
    well and tell me how you feel.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: