ASP 달력 Calendar

ASP 2015. 9. 23. 14:48 Posted by Dayis

asp_calendar.zip


1. clsCalendar.asp
<%
Class Calendar
Private cShowDate
Private cValue
Private cBorder
Private cMonth
Private cYear
Private arrMonths(12)
Private cFonts
Private cFontSize
Private cShowNav
Private cShowForm

Private Sub  Class_Initialize()
cBorder = True
arrMonths(1) = "1"
arrMonths(2) = "2"
arrMonths(3) = "3"
arrMonths(4) = "4"
arrMonths(5) = "5"
arrMonths(6) = "6"
arrMonths(7) = "7"
arrMonths(8) = "8"
arrMonths(9) = "9"
arrMonths(10) = "10"
arrMonths(11) = "11"
arrMonths(12) = "12"

cValue = Now
cMonth = Month(Now)
cYear = Year(Now)
cFonts = "Verdana"
cFontSize = 2
cShowNav = False
cShowForm = False
cShowDate = False
End Sub

Private Sub Class_Terminate()

End Sub


Public Property Let Border(byRef uBorder)
cBorder = uBorder
End Property

Public Property Get Border()
Border = cBorder
End Property


Public Property Get Value()
Value = cValue
End Property

Public Property Let Value(byRef uValue)
cValue = uValue
cMonth = Month(uValue)
cYear = Year(uValue)
End Property


Public Property Let CalMonth(byRef uMonth)
cMonth = uMonth
End Property

Public Property Get CalMonth()
CalMonth = cMonth
End Property


Public Property Let CalYear(byRef uYear)
cYear = uYear
End Property

Public Property Get CalYear()
CalYear = cYear
End Property


Public Property Let Fonts(byRef uFonts)
cFonts = uFonts
End Property

Public Property Get Fonts()
Fonts = cFonts
End Property


Public Property Let FontSize(byRef uFontSize)
cFontSize = uFontSize
End Property

Public Property Get FontSize()
FontSize = cFontSize
End Property

Public Property Let ShowNav(byRef uShowNav)
cShowNav = uShowNav
End Property

Public Property Get ShowNav()
ShowNav = cShowNav
End Property


Public Property Let ShowForm(byRef uShowForm)
cShowForm = uShowForm
End Property

Public Property Get ShowForm()
ShowForm = cShowForm
End Property


Public Property Let ShowDate(byRef uShowDate)
cShowDate = uShowDate
End Property


Public Sub Display
If cShowNav or cShowForm Then

Select Case request("CalAction")

Case "back"
cYear = request("currYear")
If request("currMonth") < 1 Then
cMonth = 12
cYear = request("currYear") - 1
Else
cMonth = request("currMonth")
End If
Case "forward"

cYear = request("currYear")
If request("currMonth") > 12 Then
cMonth = 1
cYear = request("currYear") + 1
Else
cMonth = request("currMonth")
End If
Case "goto"

cMonth = request("currMonth")
If request("currYear") <> "" Then
cYear = Int(request("currYear"))
End IF

End Select
End If


cDay = Weekday(arrMonths(cMonth) & "/" & 1 & "/" & cYear)

Days = DaysInMonth()
If cBorder Then%>
<table border="0" cellpadding=0 style="width:100%;">
<tr>
<td bgcolor="#FFFFFF">
<%End If%>
<table border="0" cellspacing=1 cellpadding=1 style="width:100%;">
<tr>
<%If cShowNav Then%>

<td align="center" class="caldateprev"><a href="<%= Request.ServerVariables("SCRIPT_NAME") %>?CalAction=back&currMonth=<%=cMonth - 1%>&currYear=<%=cYear%>" style="text-decoration:none;" class="caldate">«</a></td>
<td colspan="5"align="center" class="caldate"><%=cYear%>년 <%=arrMonths(cMonth)%>월</td>
<td align="center" class="caldatenext"><a href="<%= Request.ServerVariables("SCRIPT_NAME") %>?CalAction=forward&currMonth=<%=cMonth + 1%>&currYear=<%=cYear%>" style="text-decoration:none;" class="caldate">»</a></td>

<%Else%>
<td colspan="7"align="center" bgcolor="#666666"><font color="#FFFFFF" size=<%=cFontSize%> face="<%=cFonts%>"><b><%=arrMonths(cMonth) & " " & cYear%></b></font></td>

<%End If%>
</tr>
<tr>
<td class="yoiltitle">일</td>
<td class="yoiltitle">월</td>
<td class="yoiltitle">화</td>
<td class="yoiltitle">수</td>
<td class="yoiltitle">목</td>
<td class="yoiltitle">금</td>
<td class="yoiltitle">토</td>
</tr>
<tr>
<%i = 1
For j = 1 to cDay - 1%>
<td class="calempty"></td>
<%If i > 6 Then
response.write("</tr><tr>")
i = 0
End If
i = i + 1
Next
For j = 1 to Days%>
<td class="calday <% If i=1 Then %>sunday<% ElseIf i=7 Then %>saturday<% End if %>"><%=j%></td>
<%If i > 6 And j <= Days - 1 Then
response.write("</tr><tr>")
i = 0
End If
i = i + 1
Next
If i > 1 Then
For m = i to 7%>
<td class="calempty"></td>
<%Next
End IF%>
</tr>
</table>
<%If cBorder Then%>
</td>
</tr>
</table>
<%End If
If cShowForm Then BottomForm
End Sub


Private Sub BottomForm%>
<table border="0" cellspacing=1 cellpadding=1 width=200>
<form method="GET" action="<%= Request.ServerVariables("SCRIPT_NAME") %>">
<tr>
<td align="right" width="25%"><font color="#000000" size=<%=cFontSize%> face="<%=cFonts%>"><b>Month</b></font></td>
<td>
<select name="currMonth">
<%For i = 1 to 12%>
<option value=<%=i%><%If i = Int(cMonth) Then response.write " Selected"%>><%=arrMonths(i)%></option>
<%Next%>
</select>
</td>
<td align="right" width="25%"><font color="#000000" size=<%=cFontSize%> face="<%=cFonts%>"><b>Year</b></font></td>
<td><input type="text" name="currYear" maxlength=4 size=4  value="<%=cYear%>"></td>
</tr>
<tr><td colspan=4 align="right"><input type="submit" value="GO"></td></tr>
<input type="hidden" name="calAction" value="goto">
</form>
</table>
<%
End Sub

Private Function DaysInMonth()
Select Case cMonth
Case 1,3,5,7,8,10,12
DaysInMonth = 31
Case 4,5,6,9,11
DaysInMonth = 30
Case 2
If cYear Mod 4 Then
DaysInMonth = 28
Else
DaysInMonth = 29
End If
Case Else
Exit Function
End Select
End Function
End Class
%>


2. calendar.asp

<!--#include virtual="/lib/clsCalendar.asp"--> 

<html> 

<head> 

<title>Calendar</title>

<style type="text/css">

.yoiltitle {

text-align:center;

font-size:12px;

color:#ffffff;

padding:5px;

background:#5E9253;

}


.sunday {

color:red;

}


.saturday {

color:blue;

}


.calempty {


}


.calday {

border:1px solid #c4c4c4;

width:14%;

background:#F8FAEE;

font-size:12px;

padding:5px;

height:50px;

vertical-align:top;

}


.caldate {

font-size:16px;

font-weight:bold;

color:#5E9253;

font-family:'굴림';

padding:10px;

}

</style>

</head> 

<body> 

<div align="center"> 

<% 

Set myCal = New Calendar 

mycal.border=false 'Display Border around Calendar 

mycal.value = Now 'Sets Current Date 

mycal.calMonth = month(date) 'Sets Current Month 

mycal.calYear = year(date) 'Sets Current Year 

mycal.fonts = "Tahoma" 'Sets Font 

mycal.fontSize=2 'Sets Font Size 

mycal.showDate = True 'Not yet implemented 

mycal.showNav =True 'Show prev and next Navigation Links 

mycal.showForm = False 'Show Month and Year form 

mycal.display 'Display Calendar 

Set myCal = Nothing 

%> 

</div>

<div style="height:30px;"></div><!-- iframe에서 하단이 짤리지 않도록 추가 -->

</body> 

</html>


'ASP' 카테고리의 다른 글

쿠키(Cookies) 중복 체크 및 처리  (0) 2015.11.07
ASP 쿠키 로그인/로그아웃  (0) 2015.07.21
년월의 마지막 날짜(일) 구하기  (0) 2015.07.18
ASP 이미지 가로, 세로 크기 구하기  (0) 2015.01.19
페이지 초기번호  (0) 2015.01.04