ProcessForm 메서드는 템플릿 파일의 데이터를 사용자가 전송한 폼 데이터와 병합하여 새 파일을 만듭니다. 사용자가 전송한 데이터는 템플릿 파일의 스크립트에 의해 관리됩니다.
oTools.ProcessForm(OutputFileURL, TemplateURL, [InsertionPoint])
참고
템플릿 파일은 ASP 스크립트를 포함할 수 있습니다.
<% 와 %> 구분 기호 사이에 있는 스크립트는 템플릿 파일에 있는 다른 텍스트처럼 취급되어 출력 파일에 복사됩니다. 출력 파일이 ASP 문서이면 출력 파일이 실행될 때 스크립트가 실행됩니다.
ProcessForm을 호출하는 동안 템플릿의 스크립트가 실행되도록 하려면, 특수 <%% 및 %%> 구분 기호 사이에 코드를 둡니다. 이들 스크립트는 템플릿 데이터가 출력 파일에 저장되기 전에 실행되기 때문에 결과는 보통 표준 텍스트로 출력 파일에 저장됩니다.
지정한 출력 파일이 있는 경우 서버는 그 파일을 덮어씁니다.
InsertionPoint 매개 변수가 없으면 Tools.ProcessForm 메서드는 전체 출력 파일을 바꿉니다. InsertionPoint 매개 변수가 있고 별표(*)로 시작하지 않으면, Tools.ProcessForm 메서드는 출력 파일에서 InsertionPoint 문자열을 찾아 그 바로 뒤에 데이터를 삽입합니다. InsertionPoint 문자열이 별표(*)로 시작되면, Tools.ProcessForm 메서드는 출력 파일에서 InsertionPoint 문자열을 찾아 그 바로 앞에 데이터를 삽입합니다. InsertionPoint 문자열이 있지만 출력 파일에서 찾지 못하면 데이터가 파일 끝에 첨부됩니다.
다음은 두 파일을 사용하는 예제입니다. Tools_Template.asp는 개인 웹 페이지의 템플릿 파일입니다. 사용자가 입력하면 Tools_ProcessForm.asp는 ProcessForm을 호출하여 사용자가 업데이트한 새 파일에 템플릿 데이터를 복사합니다. Tools_ProcessForm.asp를 찾아 예제를 실행합니다.
--- Tools_Template.asp ---
<HTML>
<HEAD>
<TITLE><%% =Request.Form("company") %%></TITLE>
</HEAD>
<BODY bgcolor="<%% =Request.Form("bgcolor") %%>">
<FONT face="<%% =Request.Form("fface") %%>" size=<%% =Request.Form("fsize") %%>>
<H5 align=center>This file was created on <%% =Date %%> at <%% =Time %%></H5>
<%
Response.Write "<H3 align=center>Welcome to the home page for:</H3>"
Response.Write "<H1 align=center><%% =Request.Form("company") %%></H1>"
Set MyPageCounter = Server.CreateObject("MSWC.PageCounter")
MyPageCounter.PageHit
Response.Write "<P align=center>This page has been hit " & MyPageCounter.Hits & " times."
%>
<P><B>About my Company:</B>
<P><%% =Request.Form("about") %%>
</FONT>
</BODY>
</HTML>
--- Tools_ProcessForm.asp ---
<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>
<%
OutputURL = Request.Form("outputurl")
BGColor = Request.Form("bgcolor")
FFace = Request.Form("fface")
FSize = Request.Form("fsize")
Company = Request.Form("company")
About = Request.Form("about")
Process = True
If "" = OutputURL Then Process = False
If "" = BGColor Then Process = False
If "" = FFace Then Process = False
If "" = FSize Then Process = False
If "" = Company Then Process = False
If "" = About Then Process = False
%>
<H3>Create a Default Company Page Using the Tools_Template.asp Template</H3>
Please fill out the form. All fields are required.
<FORM NAME="GetTemplateStuff" METHOD="POST" ACTION="Tools_ProcessForm.asp">
<input type="TEXT" NAME="outputurl" size=70 value="<%=OutputURL%>"> Relative Output URL<BR>
<input type="TEXT" NAME="bgcolor" size=70 value="<%=BGColor%>"> Background Color<BR>
<input type="TEXT" NAME="fface" size=70 value="<%=FFace%>"> Font Face<BR>
<input type="TEXT" NAME="fsize" size=70 value="<%=FSize%>"> Font Size<BR><BR>
<input type="TEXT" NAME="company" size=70 value="<%=Company%>"> Company Name<BR>
<input type="TEXT" NAME="about" size=70 value="<%=About%>"> About Your Company<BR><BR>
<INPUT type="SUBMIT" VALUE="Create File">
</FORM>
<%
If Process Then
Set oTools = Server.CreateObject("MSWC.Tools")
oTools.ProcessForm OutputURL,"Tools_Template.asp","<HTML*>"
%>
<P><A href="<%=OutputURL%>"><%=OutputURL%></A> was created.
<%
Else
Response.Write "No file was created because of missing inputs."
End If
%>
</BODY>
</HTML>