How to use Visual WebGui client client invocation

In this “How to” we will going to learn how to use Visual WebGui client client invocation

You should be familiar by now with What is Visual WebGui and What is Visual WebGui over Silverlight. It is recommended that you read “How to create a Visual WebGui Silverlight application” , “How to create a Visual WebGui Silverlight custom control” and other articles in our “Get Started with Silverlight” section.

Visual WebGui (VWG) adopts the server based computing approach whereby service consumption and processing is handled on the server and human interaction is handled on the client. This model provides intrinsic benefits for enterprise applications since it provides additional measures of security and control which are not available on browser based solutions.

The Visual WebGui programming model is event based. When a control changes state, such as when the user clicks a button, it raises an event. That event runs in the server and return a metadata that describes the change that needs to be preformed in the browser. In order to handle an event, your application registers an event-handling method for that event. This behavior is good for events that need to run on the server, but if there is no need to run the action on the server we created the client client invocation mechanism that allows you to create events that run in the browser and don’t raise events to the server.

Open Visual studio and create a new Visual WebGui (VWG) application.

image

Open Form1 and add three TextBox  and four Buttons like this:

image

On the Form load add  to the first three buttons a ClientAction

this.button1.ClientAction = RegisteredClientAction.CreateWithId(this.textBox1, "Controls_Focus");

this.button2.ClientAction = RegisteredClientAction.CreateWithId(this.textBox2, "Controls_Focus");

this.button3.ClientAction = RegisteredClientAction.CreateWithId(this.textBox3, "Controls_Focus");

I used the Controls_Focus to set focus to the text box next to the button. you can use any function that the object has like Window.print, Button.Click, . You can also create your own custom controls and add functions in the java script page to the control.

Let’s run the application. Every time we click a button the focus is set to the text box next to it. The result should look like this:

image image  image

Next we’ll register a client action to the forth button and open a new page and set the URL to CNN.

this.button4.RegisterClientAction("open", "http://www.CNN.com");

Let’s run the application. On the button click a new window will open with CNN web site.

image

To summarize:
We have seen how to use Visual WebGui Client Client Invocation to save round trips to the server and how to do UI action in the browser.

You can read the original how to here

-- Eyal Albert @ Eyal.Albert (at) Gizmox.com

1 Comment

Comments have been disabled for this content.