The .NET framework provides the following tools for manag1ng user and application interfaces:
• Windows forms
• Web Forms
• Console Applications
• Web Services
These tools enable users to develop user-friendly desktop-based as well as web-based applications using a wide variety of languages on the .NET platform.
We’ll be covering the following topics in this tutorial:
Windows forms (also called Win Forms) ate used to create GUI-for Windows desktop applications. The idea of Win Form has been borrowed from Windows Foundation Classes (WFC) which was used for Visual J++. Win Form provide an integrated and unified way of developing -GUI. It has a rich variety of windows controls and user interface support.
Numerous classes and functions were used by programmers to handle GUT. MFC in VC++, direct API in C++ and VB Forms Engine in VB are just a few examples of different ways of handling GUI.
Simply Win Form is just another group of wrapper classes that deal specifically with GUI. Win Form classes encapsulate the Windows Graphical APIs. Now the programmers would not need to use the Windows Graphical APIs directly; and since Win Form has been made apart of .NET. Class Framework; all the programming languages would use the same Win Form classes. This would rid the programmers of the need to learn different· GUI classes/tools. Win Forms in the part of the namespace System Winforms.
With Win Forms we can make a single user interface, and use it in VC++, VB, C#. Using
Visual Studio. NET simply designs the GUI, by dragging the controls on a form (something that all VC++ and VB programmers are well familiar with). Now you can use the same form either in VB, VC++ or in C#. And this is all made possible because Visual Studio.NET uses the System. Winforms namespace to draw the GUI. And any language that has the appropriate CLS compliance can use this form directly.
Just as the Win Forms provide a unified way of developing GUI for desktop application, the Web Forms provide similar tool for web applications. Web Forms has been introduced in .NET as a part of ASP.NET. Web’ Forms are a form engine, that provides a browser-based user interface.
To appreciate Web Forms you may consider how GUI is rendered in current Web applications. The GUI is rendered by using HTML tags. (e.g. <input type=text name=editboxl maxlength=10 size=10 >, will draw an edit box on the web page) Web Forms can also have the intelligence to use HTML, DHTML, and WML etc. to draw the controls on the web page based on the browser’s capabilities. Web Forms can also incorporate the logic behind these controls. It’s like hooking up the code to a GUI control. Just like in your VB application, you can associate a code with a button on the web page; this code will be run on the server when the button is pressed. This is in contrast to the scripts that run on the clients when a button is pressed.
A Java programmer may consider as if each HTML control has its dedicated “Servlets” running in the background. Every time the control receives any event of interest (e.g. button pressed, selection changed etc.) this specific “Servlets” is called. This results in much cleaner code and an excellent logic separation between presentation and business logic layers.
Web Forms consist of two parts – a template, which contains HTML-based layout information for all the GUI elements and a Component which contains all the logic to be hooked to the controls or GUI elements. This provides a neat presentation layer and application logic layer separation.
The GUI will be rendered on the client side, while the code that has been hooked to the GUI elements will run on the server side (very ‘much likes a button being pressed on a JSP and a Servlets being called in response. But with Win Forms this has been made extremely easy). The incorporation of Web Forms in ASP.NET is an attempt to take ASP to a new level where it can seriously challenge JSP.
Another good feature of Web Forms is that it can be built to have enough intelligence to support a vast variety of browsers. The same ASP page would render itself using DHTML, if the browser is IE 5.5. But if the browser is Netscape the web page will be rendered using HTML tags; if the’ page is being accessed through a WAP device the same page will render itself using WML tags.
One of the obvious disadvantages of ASP over Java was that there was that an ASP code was a maintenance nightmare. While a Java programmer can use Java Beans, Tags and also Servlets to achieve presentation and business layer separation – no such mechanism was present to an ASP programmer. With ASP.NET Microsoft ‘has provided such presentation business, layer separation – by introducing the concept of Web Forms:
1. ASP.NET Web Forms provide an easy and to build dynamic Web UI.
2. ASP.NET Web Forms pages can target any browser client (there are no script library or. cookie requirements).
3. ASP.NET Web Forms pages· provide syntax compatibility with existing ASP pages.
4. ASP.NET server controls provide an easy way to encapsulate common functionality.
5. ASP.NET ships with 45 built-in server controls. Developers can also use controls built by third parties.
6. ASP.NET templates provide an easy way to customize the look and feel of list server controls.
7. ASP.NET validation controls provide an easy way to do declarative client ·or server data validation.
Console applications are command line oriented applications that allow user to read characters from the· console, write characters to the console.
Console applications are typically designed without graphical user interface and are compiled in a stand-alone executable file.
A console application is run from the command line with input and output information being exchanged between the command prompt and the running application. Because information can be written to and read from .the console window, this makes the console application a great way to learn new programming techniques without having to be concerned with the user interface.
A web service is an extension of ActiveX. Those programmers, who have used ASP and JSP both, know the apparent shortcomings of ASP. JSP has been enriched with the concepts of Beans. And Tags. ASP equivalent for Beans and Tags was ActiveX Controls. and ActiveX automation servers. Let me take a minute to explain this point a bit further. Web Services is NOT a Microsoft proprietary standard. It is a W3Consortium standard, and has been developed by Microsoft, IBM and many other big names of the industry.
Functions are of two types. The ASP built-in functions and the programmer defined implemented functions. In order to use the built in functions you just need to pass the appropriate parameters and make a simple call to these functions. The functions are implemented by the ASP itself. The string manipulation functions, Number conversion functions are an, example of built in functions.
The user-defined functions are the functions that are defined and implemented by the programmer. A programmer can either write these functions in the same asp file or can write them in another file. If the function code resides in the same asp file then the programmer can directly call that function. In case the function resides in another file, say “func.asp”; then the programmer needs to include that file by writing a statement like <!- #include file=”func.asp” ->; and now the programmer can use the function. The programmers can also make ActiveX automation servers, and call various functions of these ActiveX servers, But one limitation is very obvious – no matter which type of function you use, the function MUST physically reside on the same machine. For example your ActiveX automation server must be implemented either as a .dll or as an .exe and then must also be registered in Windows Registry before an asp code can call its functions.
In a world where the Intemet has become not only a necessity but also a way of life – it is obvious that this limitation is a strong one; Microsoft’s answer to this problem is “Web Services”. The idea goes something like this:
1. The Web service provider develops a useful function(s), and publish/advertise it. The
Web Service provider uses Web Service Description Language (WSDL) standard to describe the interface of the function(s). This is much like the Type Libraries (TLB) and Object Description Language files (ODL) that needs to be generated with the ActiveX automation servers.
2. The programmer/client who needs the function does a lookup by using a process called
– Web Service Discovery or SOAP Discovery (also called DISCO for Web Service DISCOvery)
3. The Actual communication between the client program and the web service takes place through a protocol called Simple Object Access Protocol (SOAP) -SOAP is an XML based light weight protocol used for communication in a decentralized distributed environment.