What is the use of window.external?

This is largely taken from this MSDN article but window.external can be used to allow your WebBrowserControl to execute public methods of your client Windows Forms application.

For example in your form you may have a function such as:

public void HelloFromTheForm()
{
    MessageBox.Show("Hi client, thanks for calling me!");
}

And in the html loaded into your WebBrowserControl you may have a button that looks like:

<button onclick="window.external.HelloFromTheForm()">
    Say hi to the form
</button>

So in regards to your question of 'Is this used to call the server side functions?', your form isn't 'server side' but it does allow you to call the C#/VB.NET code of your form from an embedded webpage.


It is a convention utilised by some of the browser / operating system vendors to facilitate communication between javascript running within the browser and code running "outside" of the browser on the users device or machine.

For example, if you've written a native application for Android or Windows Phone that hosts a web browser control, the surrounding native mobile framework might provide window.external as a way for javascript running on the web page within the web control to call out to your app's native code functionality. (An example of how to such things for Android can be found here: Listen to javascript function invocation from java - Android )

If, on the other hand, you're looking to communicate between the javascript running on the user's web browser and the C# code running on your server then you'll be wanting to investigate AJAX style calls (which usually has very little to do with window.external). Examples of set up such things can be found at the ASP.Net site. e.g. http://www.asp.net/web-forms/tutorials/aspnet-ajax/understanding-asp-net-ajax-web-services