아는 것이 좋은 것이다.

[ASP] 변수로 인클루드(include) 하기 본문

ASP

[ASP] 변수로 인클루드(include) 하기

start0 2014. 6. 23. 10:00
<!--#include virtual="<%=str_type%>"--> 


위와 같은 방식으로 인클루드를 할경우 오류가 난다.

<%
str_type = request("type")

If str_type = "test" then
%>
<!--#include virtual="test.asp"-->
<%
ElseIf str_type = "test2" Then
%>
<!--#include virtual="test2.asp"-->
<%
End if
%>


위와 같은 방식으로 사용은 가능하나 변수가 많아지면 비효율적이다.

<%
dirFile = request("type") & ".asp"

Server.Execute (dirFile)
%>


위와 같은 방식으로 간단하게 인클루드가 가능해진다.

'ASP' 카테고리의 다른 글

[ASP] 숫자 앞에 원하는 개수만큼 0 붙이기  (1) 2014.07.06
[ASP] XML 읽어서 출력  (0) 2014.06.28
[ASP] XMLHTTP GET으로 파일 읽어오기  (0) 2014.06.11
[ASP] ASP 쌍따옴표 replace  (0) 2014.06.05
[ASP] 랜덤함수  (0) 2014.05.23
Comments