Microsoft KB Archive/192552

= How To Create an HTML Form With DHTML Page Designer =

Article ID: 192552

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q192552



SUMMARY
This article describes how to use the DHTML Page Designer to create a simple HTML form application. Currently, the DHTML Page Designer will not insert all the tags required to do this so you need to manually insert the missing tags.



MORE INFORMATION
You can build a simple HTML form using the DHTML Page Designer. The form will have two fields and a submit button. The information will be posted to an ASP file on the server. The server will simply display the values entered in the fields. Follow these steps:

 Start Visual Basic 6.0 and create a new DHTML Application project. Open the DHTMLPage1 from Designers. From the toolbox, drag a textbox and change its NAME to Field1. Drag another textbox and change its NAME to Field2. Drag a submit button and change its VALUE to Submit. Save the project. You now need to save the HTM as an External HTML file. To do this:

<ol style="list-style-type: lower-alpha;"> Bring up the DHTML Page Designer Properties.</li> Select "Save the HTML as an External file" check box.</li> Click the "New" button.</li> Specify the location and name of the file you want.</li></ol> </li>  Click the Launch Editor button on the Designer tool bar. You will see HTML similar to the following in your editor: <BODY> <INPUT id=TextField1 name=TextField1> <P> <INPUT id=TextField2 name=TextField2> <P> <INPUT id=SubmitButton1 name=Submit1 type=submit value=Submit></P> </BODY></HTML>

Notice that there are some tags missing. First the HTML tag is missing. Secondly, there is no FORM tag. Edit the file manually to enter these tags so that the final HTM looks like the following: <HTML> <BODY> <P< <FORM ID=Form1 NAME=Form1 METHOD=POST ACTION="http://MyServer/MyDir/Test1.ASP"> <INPUT id=TextField1 name=TextField1> <P> <INPUT id=TextField2 name=TextField2> <P> <INPUT id=SubmitButton1 name=Submit1 type=submit value=Submit></P> </FORM> </BODY> </HTML>

</li> Save the file from the HTML editor and, when prompted by the designer, say Yes to reloading the file into the designer</li>  At this point, you can add some validation code. This can be done by writing the onSubmit event handler for the form as follows: Private Function Form1_onsubmit As Boolean

Dim Valid As Boolean

Valid = True If TextField1.Value = "" Then BaseWindow.alert "You must enter a value for Field1" Valid = False End If         If TextField2.Value = "" Then BaseWindow.alert "You must enter a value for Field2" Valid = False End If

Form1_onsubmit = Valid

End Function

</li> Save the Visual Basic 6.0 project.</li>  Now create the Test1.asp file you used in the ACTION attribute in your FORM tag. This file must be stored on your IIS web server. If you are not using IIS, you will not be able to use ASP. Use NotePad to save the following as test1.asp on your server: <%@ LANGUAGE="VBSCRIPT" %>

You entered the following values from your DHTML Page Designer form: TextField1 = <%=Request.Form("TextField1") %> TextField2 = <%=Request.Form("TextField2") %>

</li> Run the project. You should see the values you enter into Field1 and Field2 returned to you by the server.</li></ol>

Additional query words: kbdsi kbDSupport kbVBp kbVBp600 kbDHTML kbInternet kbPageDesigner

Keywords: kbhowto KB192552

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.