Search KB Filter article types
Creating a file name selector using a script component
Categories: Custom Controls
Tags: Developers, Events, JavaScript, 2. Intermediate, 3. Advanced, Integration, Pre v6.3, v6.3
Revision: 1
Posted: 11/Jan/2007
Updated: 11/Jan/2007
Status: Publish
Types: Code

This code sample demonstrates a script component which is used to get a file name from the user. The script component combines both a client invocation usage and raising events to provide information about the user feedback.

The code does the following:

1. Creating a custom control named MyScript which inherits from the Gizmox.WebGUI.Forms.Component class.
2. Adding a script in the same namespace as the new component with the same name but with an exstention of js (This is created by default if you create a new custom WebGUI control).
3. Making the previous resource embedded resource so the VWG server could find it.
4. To make the VWG server look for the component resources you have to register it in the web config under the controls section (see the sample's web.config for the exact format).
5. After compiling you can see the control in the toolbox and you can drag the component to the design surface. This will create the component in the InitializeComponents generated method.
6. In the embedded script component there is a method called MyScripts_GetFileName which we want to invoke on the client. We are doing it within the SelectFile method by calling client invocation using the InvokeMethodWithId service which calls the client method and by default sends the id as the first argument (We need to send the ID so we can do a callback to the server side code from the client code).
7. The client side MyScripts_GetFileName method creates a file input control and gets a path from the user. When this process is done we are raising an event to the server side code by using the event services (See the MyScripts_FileNameSelected method).
8. The server side component (MyScript) will recieve the event in the by overriding FireEvent method and handling an event called FileSelected which is the name we choose for this event in the client side code.
9. To enable callbacking the server side component we need to register the component and that is the way you see the register code. When creating a self registering component you should unregister the component your self. This part is missing but you can do it in the form close method...
 

 

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...

1. 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.
2. 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.
3. You may link to this code from another website, but ONLY if it is not wrapped in a frame.
4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


About the author

Related Articles

Custom Controls  
Title Update Author
I played a bit around with the new 6.4 ListView control, its quite amazing what you can do with it. It opens a lot of new ways to present data in a better and more userfriendly way.
Tags: Architects, Developers, Data Binding, C#, 2. Intermediate, 3. Advanced, Customization, Data Binding, v6.4 and Later
02/July/2012    2012/07/02
In this How to we are going to learn the basic usage of Visual WebGui RIA Platform Theme & Control designer.
Tags: Developers, Graphic Designers, Theme, 1. Beginner, 2. Intermediate, Customization, v6.4 and Later, 3. Advanced
04/Jan/2009    2009/01/04
Tags: Developers, Events, JavaScript, 1. Beginner, 2. Intermediate, Integration, Pre v6.3, v6.3, 3. Advanced
07/Jan/2007    2007/01/07
Tags: Developers, Graphic Designers, Theme, 1. Beginner, 2. Intermediate, Customization, v6.4 and Later, 3. Advanced
06/Jan/2009    2009/01/06
Tags: Developers, Events, JavaScript, 3. Advanced, Customization, v6.3
09/Jan/2009    2009/01/09
Code snippet for custom Drag&Drop image
Tags: Developers, Drag & Drop, Resource Handlers, C#, XSLT, 2. Intermediate, 3. Advanced, Customization, DHTML, v6.4 and Later
08/June/2011    2011/06/08
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS