In an .asp query, you need to first create the header and then the form.
This section contains:
You begin by setting up header information, as you did when creating the .htm form in the previous test drive. The <SCRIPT LANGUAGE> and </SCRIPT> turn scripting on and off. This example is turning on a Visual Basic Scripting command, option explicit.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd"> <HTML> <HEAD> <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> <!-- option explicit --> </SCRIPT> <TITLE>Index Server Search Form</TITLE> <META NAME="DESCRIPTION" CONTENT="Sample ASP query form for Microsoft Index Server"> <META NAME="KEYWORDS" CONTENT="query, content, hit, asp"> <META NAME="MS.LOCALE" CONTENT="EN-US"> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
In the preceding HTML code, the bold type contains a sampling of meta tags:
The next section turns form variables into server-side VBScript variables. The actual query form appears later in the file. Positioning the form data here allows the form fields to be pre-initialized, which causes the text of your query to reappear in the form field after the query results are displayed.
<% NewQuery = FALSE UseSavedQuery = FALSE QueryForm = Request.ServerVariables( "PATH_INFO" ) SearchString = "" if Request.ServerVariables("REQUEST_METHOD") = "POST" then SearchString = Request.Form("SearchString") pg = Request.Form("pg") if pg <> "" then NextPageNumber = pg NewQuery = FALSE UseSavedQuery = TRUE else NewQuery = SearchString <> "" end if end if %> </HEAD>
Also, the line in bold type defines the query form as the current file, in this case, Ixtrsasp.asp. From now on, the sample files is referred to as QueryForm. This line allows you to change the name of the sample file without having to change the name anywhere within the file.
Now you are ready to create the search form.
<TABLE> <TR> <TD><IMG SRC ="is2logo.gif" VALIGN=MIDDLE ALIGN=LEFT></TD> <TD><H1>Sample ASP Search Form</H1></TD> </TR> </TABLE> <HR WIDTH=75% ALIGN=center SIZE=3> <p> <TABLE> <TR> <TD ALIGN=LEFT>Enter your query below:</TD> </TR> <TR> <TD> <FORM ACTION="<%= QueryForm%>" METHOD=POST> <TABLE> <TR> <TD><INPUT TYPE="TEXT" NAME="SearchString" SIZE="60" MAXLENGTH="100" VALUE="<%=SearchString%>"></TD> <TD><INPUT TYPE="SUBMIT" NAME="Action" VALUE="New Query"></TD> </TR> </TABLE> </FORM> </TD> </TR> </TABLE>
As with the .htm form, the two most important lines are the FORM ACTION and the INPUT TYPE lines.