It looks like there has been a little bit of confusion among some people as to what I'm actually suggesting here. Not suggesting going back to ActiveX or Silverlight, or putting WPF in the browser. Let me give a more concrete example. Consider this extremely simple interactive page:
<html>
<head>
<script>
function onClick() {
main = document.getElementById("_main");
main.innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>
Hello, world!
<button onclick="onClick()">Try it</button>
</body>
</html>
In my brave new world of .NETScript (that's what I just decided to call it :)), you'd do this instead:
<!DOCTYPE html>
<html x:Class="MyApplication.HelloWorldPage">
<head>
<script x:lang="cs">
using System;
using System.NetScript;
public partial class HelloWorldPage : Page
{
public HelloWorldPage()
{
InitializeComponent();
}
private void onClick(object sender, NetScriptEventArgs e)
{
_main.InnerHTML = "Paragraph changed";
}
}
</script>
</head>
<body>
Hello, world!
<button onclick="onClick">Try it</button>
</body>
</html>
What tangible advantages does this bring? First off, we can forever lose getElementByID because the scripting engine would be smart enough to expose _main as a private class member of HelloWorldPage similar to what happens with XAML or the WinForms designer (hence partial class). Next, we'd get all .NET functionality, including multi-threading capability, for free, e.g., this would be possible:
<html x:Class="MyApplication.HelloWorldPage">
<head>
<script x:Lang="cs">
using System;
using System.Threading.Tasks;
using System.NetScript;
namespace MyApplication
{
public partial class HelloWorldPage : Page
{
TimeSpan _timeOpen;
public HelloWorldPage()
{
InitializeComponent();
}
private void onClick(object sender, NetScriptEventArgs e)
{
_main.InnerHTML = "Paragraph changed";
}
private async void onPageLoad (object sender, NetScriptEventArgs e)
{
while (true)
{
_timer.InnerHTML = _timeOpen.ToString();