VB script runs on the client inside the browser run-time.
The only C# solution I am aware of to run inside the browser, is silverlight. It is still just c# though.
You can access c# code from scripting languages like VB- of java-script, by decorating them with the [ScriptableMember] attribute, like so:
/// <summary> /// Members that can be called from javascript. (or vbscript) /// </summary> public sealed class LINEARVIEWER_SL_SCRIPTS { [ScriptableMember] public void ChangeNetwork(string pNetworkFilterId, string pNetworkFilter) { MainViewModel MainVM = (MainViewModel)((MainPage)Application.Current.RootVisual).DataContext; long SectionID; if (long.TryParse(pNetworkFilterId, out SectionID) == false) { throw new FormatException("'" + pNetworkFilterId + "' not a valid section / network ID."); } MainVM.RoadFilterViewModel.SelectSectionAsync(SectionID, /* completed handler = */ null); } }
You have to register these classes when the silverligh (c#) application starts up, like so:
private void Application_Startup(object sender, StartupEventArgs e) { ... HtmlPage.RegisterScriptableObject("LINEARVIEWER_SL_SCRIPTS", new LINEARVIEWER_SL_SCRIPTS()); }
From the java (or vb) script, you can then simply call those methods like so:
function DoAddToLIV(pNetworkFilterId, pNetworkFilter) { ... gObjLIV.Content.LINEARVIEWER_SL_SCRIPTS.ChangeNetwork(pNetworkFilterId, pNetworkFilter); ... }
where gObjLIB.Content is the id of the silverlight object inside the html page.
var gObjLIV = null; function onSilverlightPluginLoaded(sender, args) { gObjLIV = sender.getHost(); }
You can hook that function to the silverlight object in the html of ASPX page, using this parameter:
<param name="onLoad" value="onSilverlightPluginLoaded" />
Let me know if I missed anything or if you need more examples. I don't mind.