Microsoft KB Archive/260529

= How To Create a Reentrant ASP Page =

Article ID: 260529

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Active Server Pages 4.0
 * Microsoft Internet Information Server 4.0
 * Microsoft Internet Information Services 5.0
 * Microsoft Visual Basic, Scripting Edition 4.0
 * Microsoft Visual Basic, Scripting Edition 5.0

-



This article was previously published under Q260529



SUMMARY
It is possible to create a single ASP page that can both display an HTML form to gather user input, and process the values that are submitted in the form. This can be implemented by setting the ACTION parameter of the FORM tag to the same ASP page that hosts it, and writing server-side script to conditionally display the form or process the input that is submitted by using the form. Such an ASP page is called a Reentrant ASP page.

HTML forms are commonly used in Internet and intranet applications to gather user input and feedback. The information entered or selected in the HTML intrinsic controls on the form are usually submitted to an ASP page on the Web server. The ASP page processes the user inputs and generates a Response HTML page to be sent back to the client browser.

This article addresses a scripting technique that can be used to create a Reentrant ASP page.



Steps to Create a Reentrant ASP Page
The code sample in this section uses VBScript as the server-side scripting language. The following steps create a simple reentrant ASP page:  Open a new ASP file in your favorite Web page editor. Save the new file as Reentrant.asp in a virtual folder on your Web server.  Cut and paste the following code into the file: <%@Language=VBScript%> <% If Trim(Request.Form(&quot;txtName&quot;)) <> &quot;&quot; Then Response.Write &quot;You Entered the Following Details : &quot; & &quot;&quot; Response.Write &quot;Name : &quot; & Request.Form(&quot;txtName&quot;) & &quot;&quot; Response.Write &quot;Email : &quot; & Request.Form(&quot;txtEmail&quot;) & &quot;&quot; Response.Write &quot;&quot; Response.End End If %>

 



Enter Your Name : <BR> <INPUT TYPE=text NAME=txtName> <BR><BR>

Enter your E-mail address : <BR> <INPUT TYPE=text NAME=txtEmail> <BR><BR>

<INPUT TYPE=submit Value=&quot;Submit&quot;>

</FORM>

</BODY> </HTML> The HTML tags in the Reentrant.asp file define an HTML form that contains two intrinsic text box controls to accept a visitor's name and e-mail address. The ACTION parameter of the FORM tag is set to point to the same ASP page that contains it; this sets up a Reentrant page.

When a visitor submits the form after entering his or her name and e-mail address, the form is posted back to Reentrant.asp. In this example, the txtName element is used to determine whether the user input form is to be displayed, or if the Response HTML page is to be generated by the ASP in response to the form submission.

It is assumed that a value is specified in the txtName element when the form is submitted for processing. The If condition in the script checks to see if an input is provided for the txtName element. The enclosed script that generates the Response HTML page acknowledging the input received is executed when the user submits the form after entering a value in the txtName text box control on the HTML form.

The Response.End statement is required to terminate the processing of the script and to send the buffered output to the client browser. </li> Open the ASP page in your Web browser by typing in its URL. Note that the HTML form is displayed when the page opens in the browser. Enter your name and e-mail address in the text boxes on the form, and then click Submit. Note that the same ASP page now generates a Response page to acknowledge your inputs.</li></ol>

Keywords: kbhowto KB260529

-

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

© Microsoft Corporation. All rights reserved.