Sunday, November 25th, 2007
Use the Expiration line of code if you want the cookie to last globaly throughout all the browser windows. If you do not include the Expiration line and just use the one Response.Cookie(”blownies”) - “something” line the cookie will only last in this specific window until it is closed.
‘create a 10-day cookie
Response.Cookies(”brownies”) = 13Response.Cookies(”brownies”).Expires = Date() + 10
‘create a static date cookie
Response.Cookies(”name”) = “Suzy Q.”Response.Cookies(”name”).Expires = #January 1,2009#
‘you can also specify domain if going from a http to https.
Response.Cookies(”brownies”).Domain = “domain.com”
Posted in Programming | No Comments »
Thursday, November 22nd, 2007
I had to quickly post this one here. I’ve been using this quick and easy, static login script on multiple ASP applications. Just copy tha code, paste it into your code, set a password and it’s ready to go. Don’t forget to change the login form action value.
<%@ Language=VBScript
Option Explicit
Dim bLogInSaved, cmd, pw ””””””””””””””””””
‘ SET YOUR PASSWORED HEREpw = “password”
””””””””””””””””””
If Session(”letin”) = “allow” Then
bLogInSaved = True
else
bLogInSaved = False
End If
If Request.Form(”password”) <> “” Then
If Request.Form(”password”) = pw Then
Session(”letin”) = “allow”
bLogInSaved = True
else
bLogInSaved = False
End If
End If
If Request.QueryString(”logout”) = “1″ Then
Session.Contents.RemoveAll
bLogInSaved = False
End If
If bLogInSaved Then
%>
<p> PASSWORD PROTECTED PAGE GOES HERE </p>
<%
Else
Response.Write “<center><form name=”"login”"” & _
” method=”"post”" action=”"ThisPagesName.asp”">” & _
“<table width=”"345″” border=”"0″” cellspacing=”"0″” ” & _
“cellpadding=”"0″”><tr><td width=”"190″”>” & _
“<font size=”"2″” face=”"Arial, Helvetica, sans-serif”">” & _
“Please enter the Password:</font> </td>” & _
“<td width=”"155″”><input type=”"text”" ” & _
“name=”"password”"></td></tr></table>” & _
“</form></center>”
End If
%>
Posted in Programming | No Comments »
Monday, October 22nd, 2007
Turn the first letter of every word in a string to Upper case in ASP by using thes function. The original script is from http://www.scripts.com.
<%finalText = format_ucase("Every word in this string will be capitalized")
function format_ucase(tname)
do while instr(tname, " ")
temp_string = left(tname, instr(tname," " ) -1)
' ucase the first letter
format_ucase = format_ucase & ucase(mid(temp_string, 1,1))
' lcase for the rest of the word
format_ucase = format_ucase & lcase(mid(temp_string,2)) & " "
tname = right(tname, len(tname) - instr(tname," " ))
loop
'send out the rest of the word
format_ucase = format_ucase & ucase(mid(tname, 1,1))
format_ucase = format_ucase & mid(tname,2)
end function
%>
Posted in Programming | 1 Comment »
Monday, October 22nd, 2007
Turn your ASP string text to upper or lower case with ease by using these comands.
<%mySentense = "This text is going to be upper or lower case"Response.Write UCASE(mySentense) 'Upper Case
Response.Write LCASE(mySentense) 'Lower Case
%>
Posted in Programming | No Comments »
Friday, September 21st, 2007
Want to have a dynamic message that shows only for the 4th of July? Here is how I did it:
<%
Dim fourthjul, nowmonth, nowday, fourthmon
Dim fourthday, fourthmonend, fourthdayend
nowmonth = CInt(Month(date))
nowday = CInt(Day(date))
fourthmon = CInt(5)
fourthday = CInt(25)
fourthmonend = CInt(6)
fourthdayend ? CInt(5)if nowmonth >= fourthmon and nowday >= fourthday and nowmonth <= fourthmonend and nowday <= fourthdayend then
%><p><strong class="orange">Holiday Hours</strong><br />
Our Corporate Office and Customer Service will be closed<br />
<%=WeekDayName(Weekday("06-04-" & Year(date))) %>, July 4th. We will resume normal business hours on <%=WeekDayName(Weekday("06-05-" & Year(date))) %>, July 5th.<%
end if
%>
Posted in Programming | 2 Comments »