Painting a Micro Focus COBOL web form
by direct coding
I developed
a simple Micro Focus COBOL web form and started to paint it by adding a label,
a button and a textbox to it.
First, I
dragged a label from the Toolbox on to the form and changed
the text property to COBOL Message. The ID was given as lblCobolMessage. This
procedure worked fine.
Next, I
dragged a button on to the form and changed the text property to Show Me. The button ID was changed to btnShowMe.
At this
point, the Intellisense function kicks in and freezes the computer. Nothing worked. So I had to sign off and sign on again to get
back to the project.
Then, I
dragged a textbox on to the form, clear the text property to blank and gave it
an ID of txtShowMe. Again, the Intellisense
function kicks in and froze the computer.
At this
point, I thought I should go into the Default.aspx file and enter the codes
directly. This is the code for the controls in this file:
-------------------------------------------------------------------------------
<%@ Page Title="Home Page" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cbl" Inherits="WebApplication4._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Welcome to Micro Focus COBOL ASP.NET!
</h2>
<p>
To learn more about Micro Focus visit <a href="http://www.microfocus.com" title="Micro Focus Website">www.microfocus.com</a>.
</p>
<p>
<asp:Label ID="lblCobolMessage" runat="server" Text="COBOL MESSAGE"></asp:Label>
</p>
<p>
<asp:Button ID="btnShowMe" runat="server" Text="Show Me"
OnClick="btnShowMe_Click" />
</p>
<p>
<asp:TextBox ID="txtShowMe" runat="server" Text=" "></asp:TextBox>
</p>
<p>
</p>
<p>
You can also find documentation on Micro Focus COBOL at <a href="https://www.microfocus.com/support-and-services/documentation/"
title="Micro Focus Documentation">Micro Focus > Support and Services > Support Resources > Documentation</a>.
</p>
</asp:Content>
--------------------------------------------------------------------------
Next, I double-clicked the button on the webform and add the following code in the procedure division. Here is the code for the Default.aspx.cbl file:
-------------------------------------------------------------------------------
class-id WebApplication4._Default is partial
inherits type System.Web.UI.Page public.
working-storage section.
method-id Page_Load protected.
local-storage section.
procedure division using by value sender as object by value e as type EventArgs.
goback.
end method.
method-id btnShowMe_Click protected.
procedure division using by value sender as object e as type System.EventArgs.
move "Great Gatsby was here" to txtShowMe::Text
end method.
end class.
-----------------------------------------------------------------------------------------
Now Build the project and run it (Start without Debugging).
The webform should show up in the browser.
Hit the Show Me button.
The result should be "Great Gatsby was here".
-----------------------------------------------------------------------------------------
Author's Note: This is a very simple project. The objective was to show how to code for the controls on a webform if you encounter the Intellisense message. Of course, a more complicated project can be developed but you may encounter the Intellisense function. Just to clarify, I was using Windows 10, Visual Studio 19, and the latest version of Micro Focus Visual COBOL.