Execute C# Function in Windows 8 App From WebView Page

Facebook Twitter Google Digg Reddit LinkedIn Pinterest StumbleUpon Email

In last couple of blog posts we have been looking at the different use cases of WebView Control. In order to follow along with this post you should have basic understanding of WebView Control. If not, go through below posts to get the basic idea about this control.

  1. Working with the XAML WebView Control
  2. Invoking JavaScript Form Windows8 App Inside WebView Page

In this blog post we will take a look at following two scenarios.

  • How we can construct the dynamic HTML content and navigate our WebView control to that dynamically generated content.
  • how we can invoke a C# function inside our Windows 8 Application from JavaScript function.

For the first one we will be using the NavigateToString function from WebView control. And for invoking our C# function from JavaScript we will be using ScriptNotify function.

I am using the Project we built in previous blog post. You might want to quickly read through that to follow along with this post.

Constructing the Dynamic HTML in Windows 8 Application

We have added a new button, on the click event of that button we will navigate to the dynamic HTML we have constructed.


Invoking JavaScript From Windows8 App Inside WebView Page

Facebook Twitter Google Digg Reddit LinkedIn Pinterest StumbleUpon Email

In the previous blog post, we looked at basics of the WebView component. Once you are comfortable with the basic operations, you would want to perform some advanced operations. In this bog post we will examine two such advanced scenarios.

The key function we will be using to invoke the script on our HTML page is InvokeScript function provided by WebView Component.

I am using the Project we built in previous blog post. You might want to quick read through that to follow along with this post.

Adding HTML page into our Windows 8 Store Application Project

First off, let's start by creating a new HTML page in your application. I have added this HTML page in the Asset Folder.


Working with the XAML WebView Control

Facebook Twitter Google Digg Reddit LinkedIn Pinterest StumbleUpon Email

Once you start working with the Windows 8 Store application, soon you will find yourself with the requirement to show HTML pages into your native Windows 8 Store App. And sure thing, that first thing that comes to your mind is, is there any component out there which does this!! And in fact, there is.

Microsoft's Windows 8 team has provided as with the component called WebView.In this blog post we will start examining the basic features of this WebView component and in new few blog posts we will see some of the advanced scenario with this Control.

Creating The Windows 8 Application

So, to start with let's create a new Windows 8 Store Application. Certainly we will be using XAML and C# as our platform because that is where we have the issue o displaying the HTML pages.


Creating Asp .Net MVC 4 Application From Start

Facebook Twitter Google Digg Reddit LinkedIn Pinterest StumbleUpon Email

This blog post will describe a step by step process of creating a brand new MVC 4 application from scratch. The idea is to use this blog post as a reference to all the other MVC blog posts I may make on this blog. This will take out the process of repeating these steps on multiple blog posts resulting into huge blog posts.

Creating The Asp .Net MVC Application

Let's start by creating a new Asp .Net MVC 4 Empty application.