国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP技巧實例:關(guān)于對表單操作的程序_ASP教程

2024-05-04 11:03:33
字體:
供稿:網(wǎng)友

推薦:例程:用ASP判斷文件地址是否有效
以下為引用的內(nèi)容:<% Response.Write("<head><style><!--span{ font-size: 9pt }--></style></head&g

以下為引用的內(nèi)容:

Inserting Form content into Database with ASP.

<%
' -- Loader.asp --
' -- version 1.5.2
' -- last updated 12/5/2002
'
' Faisal Khan
' faisal@stardeveloper.com
' www.stardeveloper.com
' Class for handling binary uploads

Class Loader
Private dict

Private Sub Class_Initialize
Set dict = Server.CreateObject("Scripting.Dictionary")
End Sub

Private Sub Class_Terminate
If IsObject(intDict) Then
intDict.RemoveAll
Set intDict = Nothing
End If
If IsObject(dict) Then
dict.RemoveAll
Set dict = Nothing
End If
End Sub

Public Property Get Count
Count = dict.Count
End Property

Public Sub Initialize
If Request.TotalBytes > 0 Then
Dim binData
binData = Request.BinaryRead(Request.TotalBytes)
getData binData
End If
End Sub

Public Function getFileData(name)
If dict.Exists(name) Then
getFileData = dict(name).Item("Value")
Else
getFileData = ""
End If
End Function

Public Function getValue(name)
Dim gv
If dict.Exists(name) Then
gv = CStr(dict(name).Item("Value"))

gv = Left(gv,Len(gv)-2)
getValue = gv
Else
getValue = ""
End If
End Function

Public Function saveToFile(name, path)
If dict.Exists(name) Then
Dim temp
temp = dict(name).Item("Value")
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(path)
For tPoint = 1 to LenB(temp)
file.Write Chr(AscB(MidB(temp,tPoint,1)))
Next
file.Close
saveToFile = True
Else
saveToFile = False
End If
End Function

Public Function getFileName(name)
If dict.Exists(name) Then
Dim temp, tempPos
temp = dict(name).Item("FileName")
tempPos = 1 InStrRev(temp, "/")
getFileName = Mid(temp, tempPos)
Else
getFileName = ""
End If
End Function

Public Function getFilePath(name)
If dict.Exists(name) Then
Dim temp, tempPos
temp = dict(name).Item("FileName")
tempPos = InStrRev(temp, "/")
getFilePath = Mid(temp, 1, tempPos)
Else
getFilePath = ""
End If
End Function

Public Function getFilePathComplete(name)
If dict.Exists(name) Then
getFilePathComplete = dict(name).Item("FileName")
Else
getFilePathComplete = ""
End If
End Function

Public Function getFileSize(name)
If dict.Exists(name) Then
getFileSize = LenB(dict(name).Item("Value"))
Else
getFileSize = 0
End If
End Function

Public Function getFileSizeTranslated(name)
If dict.Exists(name) Then
temp = LenB(dict(name).Item("Value"))
If temp <= 1024 Then
getFileSizeTranslated = temp & " bytes"
Else
temp = FormatNumber((temp / 1024), 2)
getFileSizeTranslated = temp & " kilobytes"
End If
Else
getFileSizeTranslated = ""
End If
End Function

Public Function getContentType(name)
If dict.Exists(name) Then
getContentType = dict(name).Item("ContentType")
Else
getContentType = ""
End If
End Function

Private Sub getData(rawData)
Dim separator
separator = MidB(rawData, 1, InstrB(1, rawData, ChrB(13)) - 1)

Dim lenSeparator
lenSeparator = LenB(separator)

Dim currentPos
currentPos = 1
Dim inStrByte
inStrByte = 1
Dim value, mValue
Dim tempValue
tempValue = ""

While inStrByte > 0
inStrByte = InStrB(currentPos, rawData, separator)
mValue = inStrByte - currentPos

If mValue > 1 Then
value = MidB(rawData, currentPos, mValue)

Dim begPos, endPos, midValue, nValue
Dim intDict
Set intDict = Server.CreateObject("Scripting.Dictionary")

begPos = 1 InStrB(1, value, ChrB(34))
endPos = InStrB(begPos 1, value, ChrB(34))
nValue = endPos

Dim nameN
nameN = MidB(value, begPos, endPos - begPos)

Dim nameValue, isValid
isValid = True

If InStrB(1, value, stringToByte("Content-Type")) > 1 Then

begPos = 1 InStrB(endPos 1, value, ChrB(34))
endPos = InStrB(begPos 1, value, ChrB(34))

If endPos = 0 Then
endPos = begPos 1
isValid = False
End If

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "FileName", trim(byteToString(midValue))

begPos = 14 InStrB(endPos 1, value, stringToByte("Content-Type:"))
endPos = InStrB(begPos, value, ChrB(13))

midValue = MidB(value, begPos, endPos - begPos)
intDict.Add "ContentType", trim(byteToString(midValue))

begPos = endPos 4
endPos = LenB(value)

nameValue = MidB(value, begPos, ((endPos - begPos) - 1))
Else
nameValue = trim(byteToString(MidB(value, nValue 5)))
End If

If isValid = True Then

intDict.Add "Value", nameValue
intDict.Add "Name", nameN

dict.Add byteToString(nameN), intDict
End If
End If

currentPos = lenSeparator inStrByte
Wend
End Sub

End Class

Private Function stringToByte(toConv)
Dim tempChar
For i = 1 to Len(toConv)
tempChar = Mid(toConv, i, 1)
stringToByte = stringToByte & chrB(AscB(tempChar))
Next
End Function

Private Function byteToString(toConv)
For i = 1 to LenB(toConv)
byteToString = byteToString & Chr(AscB(MidB(toConv,i,1)))
Next
End Function
%>

1、用戶界面:
<script language="JavaScript">
function CheckAll(form)
{for (var i=0;i<form.elements.length;i )
{var e = form.elements[i];
if (e.name != 'chkall')
e.checked = form.chkall.checked;
}
}
</script>

</head>

<body>
<form method="post" action="del.asp" name="form1">
<table>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件1</td>
</tr>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件2</td>
</tr>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件3</td>
</tr>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件4</td>
</tr>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件5</td>
</tr>
<tr>
<td ><input type="checkbox" value="111" name="TradeName">電子郵件6</td>
</tr>

<tr>
<td bgcolor="#F1FBFC" height="25" colspan="2">
<p align="left"><input type="checkbox" name="chkall" value="on" onclick="CheckAll(this.form)"><font color="#FF9900">選中所有顯示的消息</font></p>
</td>
<center>


</tr>
</table>
</form>
2、刪除文件del.asp
<%
'這行寫連接數(shù)據(jù)庫的代碼
dim ID,strID
strID=""
For Each strID In Request.Form("TradeName")
ID=Cint(strID)
if strID<>"" then
DelRs = Server.CreateObject("ADODB.Recordset")
Conn.Execute "Delete From Tbname where ID="&Cstr(ID)
strID=""
end if
Next

Conn.Close
Set Conn = Nothing
Response.Redirect "成功刪除!"
%>

分享:ASP進階:用ASP判斷文件地址是否有效
<%Response.Write("<head><style><!--span{ font-size: 9pt }--></style></head>")On Error R

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊宁市| 浑源县| 阜平县| 名山县| 加查县| 香河县| 台前县| 柏乡县| 栖霞市| 镇平县| 讷河市| 铁岭市| 连南| 广南县| 宝兴县| 通化县| 珠海市| 兴隆县| 剑河县| 新蔡县| 武冈市| 天祝| 德兴市| 皮山县| 射阳县| 阜南县| 清涧县| 高阳县| 刚察县| 双牌县| 崇义县| 龙江县| 云南省| 林芝县| 凌云县| 石屏县| 宾川县| 望谟县| 温宿县| 湘阴县| 沂水县|