FormManager Fun in Visual InterDev 6

FormManager Fun in Visual InterDev 6

his article takes a first look at the FormManager, one of the important new featuresin Visual InterDev 6. When dropped onto an Active Server Pages (ASP) page, the FormManagerdesign-time control (DTC) resembles a puppet master. By pulling the right strings, youmanipulate the properties and behavior of other objects in a Web page form. Form objectscan include buttons, text fields and even labels. By setting “modes” in theFormManager, a single scripted page can act like many different pages. Rather thancreating separate forms for Adding, Updating and Deleting database records, you can assignthose modes to one script.

Create a “Form About Nothing”
Although forms are usually linked to database fields, the form in this article doesn’tuse any external data. In fact, you might call it “The form about nothing”. I’mgoing to demonstrate some useful features of the FormManager by using it to create an ASPscript. You’ll see how to use events to change the properties of form objects?all inserver-side script. To orient you to the goal, Figure 1 shows the end result of whatwe’re building.

Let’s start by opening a VID6 project and adding an ASP file such as”default.asp”. Make sure that the Visual InterDev 6 script libraries are in yourproject.  I have my themes and layouts set to “” to keep thepage simple. You’ll also need to add two GIF images of the same dimensions to the Imagesfolder of the  project. You can download my images and all of the code here.

We’ll be working in VID’s design view most of the time, so you’ll want to click theDesign tab at the bottom of the working pane. Since FormManager is a design-time control,make sure your Toolbox is visible and then click the Design-Time tab. The Toolbox shouldlook like Figure 2.

To add the FormManager DTC, click FormManager, drag the icon to your page, and drop thecontrol. The first time you drop one of these controls, VID asks you (see Figure 3) to enable its Scripting ObjectModel. Click Yes.

Now let’s start designing the form. First, insert a table on the page by clicking theTable menu and clicking Insert Table. You want three rows, two columns, and a border. Don’tallow text to wrap. Figure 4 shows howthe dialog box should look.

You Can Add Buttons that Don’t Appear at Run-time
For this demonstration, you are going to put these controls on theform: two buttons, two button images, a text label and a checkbox. You’ll notice in thefinished product that at run time our ASP page displays only one of each type of control.Let’s add the various objects into the table cells.

Tip:    Be careful to select the Design-Time versions of these objects, not the plain old HTML versions.

Drag and drop a button DTC into the top row of column one. Right-click thebutton and bring up the button’s  property page. (Selecting an item to get at itsproperties can be tricky. Sometimes you need to click away from the object and then clickon its border to make the selection or resize cursor appear.) Set the properties of thisbutton as follows:

Name: ChangeButton
Caption: Make Changes
Visible: checked

Tip:    Give objects meaningful names as you create them. Later on, when you are manipulating the objects with the FormManager, you’ll find it easier to recognize them. Otherwise, you might be stuck guessing which is Button1 and which is Button10.

Figure 5 shows how theproperty page should look once you’ve added the name and caption.

Add another button DTC to the same cell. When you start using theFormManager, you’ll make sure that only one button appears on the form at run time. Hereare the properties to set for the second button:

Name: UndoButton
Caption: Undo Changes
Visible: not checked

Figure 6 shows how theUndoButton’s property page should look once you’ve added the name and caption.

The next two buttons will actually be buttons that are images. (Thepictures are the flags of the two Canadian provinces in which I have lived.) Once again,only one image/button will appear on the screen at run time but we need to insert both atdesign-time. In the top row of the second column, drop a button. Set its properties asfollows:

Name: OntImageButton
Image: images/ontario.gif
Alternate text: Ontario flag
Visible: checked

Figure 7 shows how theOntario flag image button’s property page should look.

Add the second image button with these properties:

Name: QuebecImageButton
Image: images/quebec.gif
Alternate text: Quebec flag
Visible: not checked

Server-side Script in the DTC Controls Checkboxes Too
The final two controls, a label and a checkbox, will help demonstratehow the FormManager lets you manipulate numerous properties. Drag a label DTC into thesecond row of column two and set these properties:

Name: Label1
Field/Expression: Ontario
Color: Blue
Visible: checked

Figure 8 shows theappearance of the General tab, and Figure9 shows where you set the label text color to blue.

Drag a checkbox DTC into the third row of the second column and set theseproperties:

Name: Checkbox1
Caption: Ottawa is in this province
Enabled: not checked
Visible: checked

In Figure 10, you seehow the initial properties of the checkbox should appear.

Now that you’ve finished adding objects to the form, your screen VisualInterDev 6 working page should look like Figure11.

If you’re curious, view the page in your browser. It should look like Figure 12.

Modes Are Like Separate Pages Using One Page
At last you’re ready to play with the FormManager and create someserver-side script. Select the FormManager and view its properties. On the Form Mode tab,you’ll find a group box called States, and in the group box, a field called New Mode. Sofar, you don’t have any modes, but you need at least one. Think of modes as the identifiersfor distinct ASP pages?except that FormManager keeps them all in one page. For this smalldemo, you’re only going to use one mode, called Flip. Type Flip as the New Mode box andthen click the right arrow (>) to add Flip to the list of available modes. Make theForm Mode tab look like Figure 13.

Now that you have a mode, you can start manipulating objects within theform. Click the Action tab. This page isn’t very intuitive in its design, but it makes upfor it in functionality. Across the top, you see four columns: Current Mode, Object, Eventand Next Mode. Click in the Current mode field and you’ll notice that you can select Flip,the mode we just added.  Set these properties and then you can consider whatthis means in plain English:

Current Mode: Flip
Object: ChangeButton
Event: onclick
Next Mode: Flip

And in the bottom area for actions, set these properties:

Object: ChangeButton
Member: hide
Value: ()

Figure 14 shows howyour FormManager Action tab should look.

Put the FormMode Settings into Plain English
It helps to put these FormManager settings into a couple of sentences. Forthis one, the instructions for the run-time activity go like this:

“When our Current Mode is Flip and the Object(button) called ChangeButton fires an onclick Event(that is, the button is clicked), set the Next Mode to the mode called Flip.Also, whenever ChangeButton is clicked, make the Object called ChangeButtondisappear by running the Member routine called hide. There’s noneed to set any Value for hide so just insert ().”

If you close the property page and view the ASP page in your browser,you’ll discover that FormManager is following the instructions. When you click the MakeChanges button, the hide routine makes the button disappear. You may recall that you addedtwo buttons into that cell. Let’s add more commands to display the second button whilehiding the first button and change the images.  Go back into the properties ofFormManager and add more actions on the Action tab. Click in the second row of the lowergrid and set these parameters:

Object Member Value
UndoButton show ()
OntImageButton hide ()
QuebecImageButton show ()

Your Action tab should look like Figure 15 after you’ve finished enteringthe data.

Close the property page, save the file, view the page in the browser andclick the Make Changes button. You notice two changes: the Undo Changes button and theQuebec flag are now showing. For the sake of accuracy, you need to make two more tweaks to your form. The label should be “Quebec” when the Quebec flag is showing. SinceCanada’s capital city, Ottawa, is not in Quebec, the checkbox control should be enabledbut unchecked. Notice that we don’t need to add a second label object because we can alterthe text of the existing label.

Back in the FormManager’s Action tab, here’s what you need to add:

Object Member Value
Label1 setCaption (‘Quebec’)
Checkbox1 disabled 0
Checkbox1 setChecked (0)

Some Routines in the DTC Take Parameters
Notice that the label DTC calls on a routine that changes the caption(setCaption) but you have to supply the value (‘Quebec’) as a parameter. Likewise, withthe checkbox DTC you enable the control by setting the disabled property to zero. Bysetting setChecked to zero you tell the DTC that you want the checkbox cleared. Figure 16 demonstrates what you shouldsee when you view the page in the browser and click the Make Changes button.

At this point you have a button labeled Undo Changes that doesn’t do?orundo?anything. To make it work, you need to go back to the FormManager, add a transitionrow for UndoButton that is similar to the first row you previously created there, and thenset this series of actions for UndoButton’s onclick event:

Object Member Value
QuebecImageButton hide ()
OntImageButton show ()
Checkbox1 setChecked (1)
UndoButton hide ()
ChangeButton show ()

Figure 17 shows thetwo form mode transitions and some of the actions that take place when you click thebutton called UndoButton.

I’ll leave it to you to fix some of the cosmetic problems, like centeringthe controls within the table cells, removing the table border and adding a heading to thepage. You can download my code here. Note that the download doesnot include the VID 6 script library files that you need to have installed on the Webserver.

Server-side Code Isn’t the Most Efficient
If you’re familiar with the onClick event in Visual Basic or DHTML, you’llrecognize the concept of using one click to change the properties of objects all over theplace. Unfortunately, in the HTML world implementing the changes requires a round-trip tothe server. All of this could be done quite nicely and efficiently as Dynamic HTML if onlyall browsers would support DHTML. Until then, we can do a creditable job with server-sidecode and design-time controls to make the coding easy.

In this article, you’ve seen how you can use the Visual InterDev 6FormManager design-time control to create an event-driven form. With the form you canchange the properties of HTML objects on the click of a button. You’ve seen that the eventcode runs on the Web server and the server sends only regular HTML to the browser. Fromhere, you can explore more of Visual InterDev’s DTCs, including the textbox, listbox andoptiongroup.

devx-admin

devx-admin

Share the Post:
Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a

Chinese 5G Limitation

Germany Considers Limiting Chinese 5G Tech

A recent report has put forth the possibility that Germany’s Federal Ministry of the Interior and Community may consider limiting the use of Chinese 5G technology by local network providers

Modern Warfare

The Barak Tank is Transforming Modern Warfare

The Barak tank is a groundbreaking addition to the Israeli Defense Forces’ arsenal, significantly enhancing their combat capabilities. This AI-powered military vehicle is expected to transform the way modern warfare

AI Cheating Growth

AI Plagiarism Challenges Shake Academic Integrity

As generative AI technologies like ChatGPT become increasingly prevalent among students and raise concerns about widespread cheating, prominent universities have halted their use of AI detection software, such as Turnitin’s

US Commitment

US Approves Sustainable Battery Research

The US Department of Energy has revealed a $325 million commitment in the research of innovative battery types, designed to enable solar and wind power as continuous, 24-hour energy sources.

Netanyahu Musk AI

Netanyahu and Musk Discuss AI Future

On September 22, 2023, Israeli Prime Minister Benjamin Netanyahu met with entrepreneur Elon Musk in San Francisco prior to attending the United Nations. In a live-streamed discussion, Netanyahu lauded Musk

Urban Gardening

Creating Thriving Cities Through Urban Gardening

The rising popularity of urban gardening is receiving increased recognition for its numerous advantages, as demonstrated in a recent study featured in the Environmental Research Letters journal. Carried out by

What You Need to Know About Cloud Security Strategies

What You Need to Know About Cloud Security Strategies

Today, many businesses are adopting cloud computing services. As a result, it’s important to recognize that security measures for data in the cloud are different from those in traditional on-premises

Romanian Energy Security

Eastern Europe is Achieving Energy Security

Canada and Romania have solidified their commitment to energy security and independence from Russian energy exports by signing a $3-billion export development agreement. The deal is centered on constructing two

Seamless Integration

Unlocking Seamless Smart Home Integration

The vision of an intelligently organized and interconnected smart home that conserves time, energy, and resources has long been desired by many homeowners. However, this aspiration has often been hindered

New Algorithm

MicroAlgo’s Groundbreaking Algorithm

MicroAlgo Inc. has revealed the creation of a knowledge-augmented backtracking search algorithm, developed through extensive research in evolutionary computational techniques. The algorithm is designed to boost problem-solving effectiveness, precision, and

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses