Click here to Skip to main content
Licence 
First Posted 17 Apr 2003
Views 65,525
Bookmarked 31 times

Detecting .NET Availability

By | 17 Apr 2003 | Article
In this article, we would see how to detect whether .NET Runtime/SDK is available on the client machine

Introduction

Making simpler Controls in Windows Forms and exposing them as ActiveX Controls has never been easier before .NET. But the catch is that at least the .NET Runtime must be available on the client machine before the OBJECT tag can be manipulated via JavaScript or there would be runtime errors in the rendered page.

Detecting .NET Runtime

Fortunately, when you install .NET SDK/Runtime, it plugs in to the Client Machine Web Browser, so that the UserAgent Field now also contains a string to reflect CLR availability for scripts. The UserAgent Field now also contains Build Version. But the Revision is not being carried into the UserAgent, as the JavaScript shows.

The Method

Just use the following simple JavaScript to detect whether you have .NET CLR installed for use from with Internet Explorer or not.
  if ((navigator.userAgent.indexOf(".NET CLR")>-1)) 
      alert ("CLR available " +navigator.userAgent);
  else
      alert(".NET SDK/Runtime is not available for us from within " + <BR>           "your web browser or your web browser is not supported." + <BR>           " Please check with http://msdn.microsoft.com/net/ for " + <BR>           "appropriate .NET runtime for your machine.");

How To Use

Using a simple Windows Form Control as ActiveX Controls in WebPages is quite simple. Make a simple C#/VB.NET Class Library. Build the application. Copy the DLL from the bin folder into an appropriate WebRoot. Now you can refer this Component from simple OBJECT tag variant.
<object id="DeepakControl" name="DeepakControl" <BR>    classid="DeepakAlert.Dll#LavanyaDeepak.DeepakAlert" VIEWASTEXT <BR>    width="0" height="0">
</object>
Now you can refer the DLL and its Public Methods/Properties by simple JavaScript Assignments. All unhandled exceptions will be shown as Internet Explorer MessageBoxes.

Conclusion

I hope the above article would really be very useful for many developers worldwide in making simple and elegant ActiveX Controls using C#/Windows Forms and exposing them using OBJECT tag.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vasudevan Deepak Kumar

Web Developer

India India

Member

Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College (now VIT University). He also has a MBA in Systems from Alagappa University, Karaikudi, India.


He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000. For sometime, he has also been with PHP and MySQL based development in one of his previous organizations. Now currently his focus is on Microsoft .NET World (ASP.NET, C# and Whidbey)


In his past-time, he listens to polite Carnatic Music.

Web Presence


Homepage

http://www.lavanyadeepak.tk/

Blogs



Technical




Gossips



Spiritual







Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionA personal query PinmemberSkpananghat21:05 28 Jun '07  
AnswerRe: A personal query PinmemberVasudevan Deepak Kumar1:55 29 Jun '07  
QuestionIs there any utility available to find the versions? PinmemberMadhanSeran0:33 24 Jul '06  
GeneralInvoking method in C# assembly from Javascript PinmemberKiran Kamath0:17 16 Oct '03  
GeneralRe: Invoking method in C# assembly from Javascript PineditorHeath Stewart3:06 16 Oct '03  
QuestionHow about PinmemberDavid Stone18:35 19 Apr '03  
AnswerRe: How about PinmemberDeepak Kumar Vasudevan22:40 19 Apr '03  
AnswerRe: How about Pinmemberkgrubbs8:05 12 Jun '03  
Generalhumbug Pinmemberdog_spawn6:01 19 Apr '03  
Generalmore words... Pinmember.S.Rod.3:02 19 Apr '03  
General2 words Pinmemberleppie10:28 18 Apr '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 18 Apr 2003
Article Copyright 2003 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid