Published on: Monday, April 28, 2008
By: gailsteiger
User Rating:
Categories: Interopability,
Library,
C#,
JavaScript
Users have accessed this code article 1468 times.
These 2 projects demonstrate passing parameters to and retrieving parameters from a VisualWebGui application running in a Modal Dialog. This is achieved using a WGAdapter.
The WGAdapter is a primarily client side component that launches a VWG application from another application, in this case, a simple ASP.NET app called Gizmox.WebGUI.Adapters.AspNet.Testing. The adapter is created in the ASP.NET application, which opens the Modal Dialog and launches the VWG application, in this case, Gizmox.WebGUI.Adapters.AspNet.Testing.Site.
To use the WGAdapter you must add a reference to Gizmox.WebGUI.Adapters.AspNet to your project and register the adapter by adding the following code to the system.web section of the web.config file:
<httpHandlers>
<addverb="*"path="WGAdapter.aspx"type="Gizmox.WebGUI.Adapters.AspNet.WGAdapter, Gizmox.WebGUI.Adapters.AspNet" />
</httpHandlers>
The Gizmox.WebGUI.Adapters.AspNet.Testing.Site, the VWG application, looks for incoming parameters in this.Context.Arguments and places outgoingparameters in this.Context.Results. The VWG application builds a directory tree based on the value in this.Context.Arguments[“RootPath”]. When the forms closes, the path of the folder represented by the selected tree node is returned by placing it in this.Context.Results[“Folder”].
Gizmox.WebGUI.Adapters.AspNet.Testing is an ASP.NET application, which opens the above VWG application in a Modal Dialog using a WGAdapter, which also serves to pass parameters to and retrieve parameters from the VWG application. The user types the RootPath in a textbox. Clicking the GetFolder button executes the OpenWindow()JavaScript function, which creates an instance of the WGAdapter and launches the VWG application in a Modal Dialog as follows:
var objAdapter = new WGAdapter("http://localhost:4064");
var objResults = objAdapter.ShowDialog("Form1",objArgs,600,600);
Here is an explanation of the method arguments:
· “http://localhost:4064” is the application domain of the VWG application.
· "Form1"isthe name of the application, as described in its project web.config file Applications section.
· objArgs is an object containing the parameters.
· The last 2 arguments are the width and height of the window.
The VWG application retrieves the arguments from Context.Arguments and passes arguments back to the referrer by placing them in Context.Results.
The ASP.NET application retrieves the results from the objResults variablereturn by the ShowDialog method.
Please note that, at the present time, this works only with Internet Explorer.
We are currently working on an alternative method to interact with a VWG application which will be available the same way you use other “mashups” solutions, such as GoogleMaps and Virtual Earth. This means that you will be able to embed and call VWG applications and dialogs from any site using client side scripting. This will be a cross browser solution and will allow easy integration with a VWG application across domains.
Note: Codes are submitted as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Terms of Agreement:
By using this code, you agree to the following terms...
- You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
- You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
- You may link to this code from another website, but ONLY if it is not wrapped in a frame.
- You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.