I also tried to help you out on that Stack Overflow thread of your question, the problem actually is that you shouldn't actually ask the server-side code to take over the client-side code too. If you have to then you have to register the code at the start-up and then execute it.
But, another solution, which I provided there too, is that you need to determine the browser only. Then you can make a good use the
Request.Browser
object, to check the properties of the browser. It would give you details about the browser itself, and can be used in the server-side C# code.
Otherwise, the JavaScript code as Solution 1 says, must be executed in the client-side code environment (by JavaScript only). You can make up a file, and reference that file in your actual HTML DOM, or you can write that in a
script
element in your HTML DOM. But still it won't be as much efficient as it can be to perform all these checks at the server-side using that Request.Browser object.
You can read the
MSDN document[
^] about the Request.Browser and different members it exposes for you to work out in determining the browsers.
How to: Detect Browser Types and Browser Capabilities in ASP.NET "Web Forms (Same underlying code; don't panic)"[
^]