On this page we want to ensure that ScriptX is available and if not, redirect to a page that will assist with the install. To reduce complexity, this and the helper page do no printing.
The ScriptX object is added to the page with no codebase, just the required version:
<object codebase="#Version=8,3,0,4" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory"> </object>
Javascript can then check if ScriptX is available and redirect to the helper page if not:
<script type="text/javascript"> function MeadCo_ScriptX_CheckInstalled() { var f = document.getElementById("factory"); if ( f==null || typeof(f)=="undefined" || f.object == null ) { window.location = "/InstallHelper/Install"; } } if ( window.addEventListener ) { window.addEventListener('load',MeadCo_ScriptX_CheckInstalled,false); } else { window.attachEvent("onload",MeadCo_ScriptX_CheckInstalled); } </script>
All of the above can be generated for you by the MeadCo ScriptX Helpers for ASP.NET MVC package:
@ClientPrinting.GetHtml(clientValidationAction: ClientPrinting.ValidationAction.Redirect)
This sample is using a modified version of the generated code so that this page appears and prompts for the install instead of automatically redirecting to the helper page.