asp源码模板
Ⅰ 帮忙x写一个简单的asp网页源代码
如果user表存在并且设计好。
假设字段分别为id,name,classname
那么如下代码即可。
name=request("name")
classname=request("classname")
set rs=server.createobject("adodb.recordset")
rs.open "select * from user",conn,1,3
rs.addnew
rs("name")=name
rs("classname")=classname
rs.update
rs.close
html的表单部分,用你的那2个文本框来输入就可以了。name和classname可以根据你自己的需要来改名。
多动手,祝你成功。
Ⅱ 谁能提供一个最简单易懂的ASP上传图的代码
以下是一个无组建上传,代码没有测试,调试一下就应该可以使用。
uploadfile.asp的内容
=====================================================
<!-- #include file="upload.inc" -->
<%
dim strFormName, strInputName
dim intFileID
strFormName = request.querystring("formname")
strInputName = request.querystring("inputname")
intFileID = ls.cdata(request.querystring("fileid"), 3)
if request.querystring("up") = "ok" then
if request.querystring("uploadcode") = Session("UploadCode") then
Session("UploadCode") = ""
Server.ScriptTimeOut = 999999
Dim Upload
Dim FileToBinary
Dim strMsg, strImageTypes
strMsg = "上传成功!"
strImageTypes = "jpg,gif,bmp,jpeg,png,tif,iff"
Set Upload = New UpFile_Class
Upload.InceptFileType = ""
Upload.MaxSize = 1024*1024
Upload.GetDate() '取得上传数据
FileToBinary = Null
If Upload.Err > 0 then
Select Case Upload.Err
Case 1 : strMsg = "请先选择你要上传的文件!"
Case 2 : strMsg = "文件大小超过了限制 1024KB!"
Case 3 : strMsg = "文件类型不正确!"
End Select
ls.Redirect strMsg, "close"
Else
Dim FormName, File, FileExt, FileName, FileType
FormName = "up_file"
Set File = Upload.File(FormName)
FileExt = FixName(File.FileExt)
FileName = FormatName(FileExt)
FileType = CheckFiletype(FileExt)
If File.FileSize > 0 and Instr("," & strImageTypes & ",", "," & FileExt & ",") > 0 Then
File.SaveToFile Server.Mappath(BasePath & UploadFileFolder & FileName)
Else
response.write "没有文件上传,或图片不是以下“jpg,gif,bmp,jpeg,png,tif,iff”类型的一种。" End If
End If
Set Upload = Nothing
else
response.write "请不要重复提交!", "close"
end if
else
Dim PostRanNum
Randomize
PostRanNum = Int(900*rnd)+1000
Session("UploadCode") = Cstr(PostRanNum)
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>上传图片</title>
<link href="../style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
#up_body {
height: 92px;
width: 402px;
border: #6595D6 1px solid;
}
#up_img {
height: 90px;
width: 120px;
float: left;
text-align:center;
}
#up_upload {
float: left;
height: 90px;
width: 280px;
}
#up_message {
float: left;
height: 90px;
width: 260px;
padding-top:30px;
text-align:center;
}
#up_form {
margin: 0px;
padding: 0px;
border: 0px;
}
#up_label {
background-color: #E4EDF9;
height: 30px;
width: 280px;
font-size-adjust: 14px;
font-weight: bold;
}
#up_label {
font-size: 14px;
font-weight: bold;
background-color: #E4EDF9;
width: 280px;
text-align:center;
line-height:180%;
}
#up_input {
height: 30px;
width: 280px;
}
#up_file {
margin-top:4px;
width: 280px;
}
#up_button {
width: 280px;
text-align:center;
}
-->
</style>
<script type="text/javascript">
<!--
function change()
{
up_upload.style.display="none";
up_message.style.display="";
}
-->
</script>
</head>
<body>
<div id="up_body">
<div id="up_upload">
<form action="uploadfile.asp?up=ok" method="post" enctype="multipart/form-data" name="up_form" id="up_form">
<div id="up_label">上 传 图 片</div>
<div id="up_input">
<input type="file" name="up_file" id="up_file" />
</div>
<div id="up_button">
<input type="submit" name="Submit" value="提交" onclick="change()" />
<input type="button" name="Submit2" value="关闭" onclick="window.close()" />
</div>
</form>
</div>
<div id="up_message" style="display:none;">
请稍后,文件上传中....
</div>
</div>
</body>
</html>
upload.inc的内容
====================================================
<%
'----------------------------------------------------------------------
'转发时请保留此声明信息,这段声明不并会影响你的速度!
'******************* 无惧上传类 V1.0 *********************************
'作者:梁无惧
'网站:http://www.25cn.com
'电子邮件:[email protected]
'版权声明:版权所有,源代码公开,各种用途均可免费使用,但是修改后必须把修改后的文件
'发送一份给作者.
'***********************************************************************
'***********************************************************************
'上传类强化记录
'修改者:Fssunwin
'----------------------------------------------------------------------
'添加以下属性:
'InceptFileType 允许上传的文件类型,以英文逗号“,”分隔。
'添加以下方法:
'FileWidth 图片宽度
'FileHeight 图片高度
'----------------------------------------------------------------------
'***********************************************************************
Dim oUpFileStream
Class UpFile_Class
Public Form,File,Version,Err
Private CHK_FileType,CHK_MaxSize
Private Sub Class_Initialize
Version = "无惧上传类 Version V1.0"
Err = -1
CHK_FileType = ""
CHK_MaxSize = -1
Set Form = Server.CreateObject ("Scripting.Dictionary")
Set File = Server.CreateObject ("Scripting.Dictionary")
Set oUpFileStream = Server.CreateObject ("Adodb.Stream")
Form.CompareMode = 1
File.CompareMode = 1
oUpFileStream.Type = 1
oUpFileStream.Mode = 3
oUpFileStream.Open
End Sub
Private Sub Class_Terminate
'清除变量及对像
Form.RemoveAll
Set Form = Nothing
File.RemoveAll
Set File = Nothing
oUpFileStream.Close
Set oUpFileStream = Nothing
End Sub
Public Property Get InceptFileType
InceptFileType = CHK_FileType
End Property
Public Property Let InceptFileType(Byval vType)
CHK_FileType = vType
End Property
Public Property Get MaxSize
MaxSize = CHK_MaxSize
End Property
Public Property Let MaxSize(vSize)
If IsNumeric(vSize) Then CHK_MaxSize = Int(vSize)
End Property
Public Sub GetDate()
'定义变量
Dim RequestBinDate,sSpace,bCrLf,sInfo,iInfoEnd,tStream,iStart,oFileInfo
Dim sFormValue,sFileName,sFormName,RequestSize
Dim iFindStart,iFindEnd,iFormStart,iFormEnd,FileBlag
'代码开始
RequestSize = Int(Request.TotalBytes)
If RequestSize < 1 Then
Err = 1
Exit Sub
End If
Set tStream = Server.CreateObject ("Adodb.Stream")
oUpFileStream.Write Request.BinaryRead (RequestSize)
oUpFileStream.Position = 0
RequestBinDate = oUpFileStream.Read
iFormEnd = oUpFileStream.Size
bCrLf = ChrB (13) & ChrB (10)
'取得每个项目之间的分隔符
sSpace = MidB (RequestBinDate,1, InStrB (1,RequestBinDate,bCrLf)-1)
iStart = LenB (sSpace)
iFormStart = iStart+2
'分解项目
Do
iInfoEnd = InStrB (iFormStart,RequestBinDate,bCrLf & bCrLf)+3
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iFormStart
oUpFileStream.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sInfo = tStream.ReadText
'取得表单项目名称
iFormStart = InStrB (iInfoEnd,RequestBinDate,sSpace)-1
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = Mid(sinfo,iFindStart,iFindEnd-iFindStart)
'如果是文件
If InStr(45,sInfo,"filename=""",1) > 0 Then
Set oFileInfo = new FileInfo_Class
'取得文件属性
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid(sinfo,iFindStart,iFindEnd-iFindStart)
oFileInfo.FileName = Mid(sFileName,InStrRev(sFileName, "\")+1)
oFileInfo.FilePath = Left(sFileName,InStrRev(sFileName, "\"))
oFileInfo.FileExt = Lcase(Mid(sFileName,InStrRev(sFileName, ".")+1))
iFindStart = InStr (iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr (iFindStart,sInfo,vbCr)
oFileInfo.FileType = Ucase(Mid(sinfo,iFindStart,iFindEnd-iFindStart))
oFileInfo.FileStart = iInfoEnd
oFileInfo.FileSize = iFormStart -iInfoEnd -2
oFileInfo.FormName = sFormName
If Instr(oFileInfo.FileType,"IMAGE/") Or Instr(oFileInfo.FileType,"FLASH") Then
FileBlag = GetImageSize
oFileInfo.FileExt = FileBlag(0)
oFileInfo.FileWidth = FileBlag(1)
oFileInfo.FileHeight = FileBlag(2)
FileBlag = Empty
End If
If CHK_MaxSize > 0 Then
If oFileInfo.FileSize > CHK_MaxSize Then
Err = 2
Exit Sub
End If
End If
If CheckErr(oFileInfo.FileExt) = False Then
Exit Sub
End If
File.Add sFormName,oFileInfo
Else
'如果是表单项目
tStream.Close
tStream.Type = 1
tStream.Mode = 3
tStream.Open
oUpFileStream.Position = iInfoEnd
oUpFileStream.CopyTo tStream,iFormStart-iInfoEnd-2
tStream.Position = 0
tStream.Type = 2
tStream.CharSet = "gb2312"
sFormValue = tStream.ReadText
If Form.Exists (sFormName) Then _
Form (sFormName) = Form (sFormName) & ", " & sFormValue _
Else _
Form.Add sFormName,sFormValue
End If
tStream.Close
iFormStart = iFormStart+iStart+2
'如果到文件尾了就退出
Loop Until (iFormStart+2) = iFormEnd
RequestBinDate = ""
Set tStream = Nothing
End Sub
'====================================================================
'验证上传类型
'====================================================================
Private Function CheckErr(Byval ChkExt)
CheckErr=False
If CHK_FileType > "" Then
If InStr("," & Lcase(CHK_FileType) & ",", "," & ChkExt & ",")>0 Then
CheckErr = True
Else
Err = 3
End If
Else
CheckErr = True
End If
End Function
'====================================================================
'图像宽高类型读取
'====================================================================
Private Function Bin2Str(Byval Bin)
Dim i, Str, Sclow
For i = 1 To LenB(Bin)
Sclow = MidB(Bin,i,1)
If ASCB(Sclow)<128 Then
Str = Str & Chr(ASCB(Sclow))
Else
i = i+1
If i <= LenB(Bin) Then Str = Str & Chr(ASCW(MidB(Bin,i,1)&Sclow))
End If
Next
Bin2Str = Str
End Function
Private Function Num2Str(Byval num,Byval Base,Byval Lens)
Dim ImageSize
ImageSize = ""
While(num>=Base)
ImageSize = (num mod Base) & ImageSize
num = (num - num mod Base)/Base
Wend
Num2Str = Right(String(Lens,"0") & num & ImageSize,Lens)
End Function
Private Function Str2Num(Byval str,Byval Base)
Dim ImageSize,i
ImageSize = 0
For i=1 To Len(str)
ImageSize = ImageSize *Base + Cint(Mid(str,i,1))
Next
Str2Num = ImageSize
End Function
Private Function BinVal(Byval bin)
Dim ImageSize,i
ImageSize = 0
For i = lenb(bin) To 1 Step -1
ImageSize = ImageSize *256 + ASCB(Midb(bin,i,1))
Next
BinVal = ImageSize
End Function
Private Function BinVal2(Byval bin)
Dim ImageSize,i
ImageSize = 0
For i = 1 To Lenb(bin)
ImageSize = ImageSize *256 + ASCB(Midb(bin,i,1))
Next
BinVal2 = ImageSize
End Function
Private Function GetImageSize()
Dim ImageSize(2),bFlag
bFlag = oUpFileStream.Read(3)
Select Case Hex(BinVal(bFlag))
Case "4E5089":
oUpFileStream.Read(15)
ImageSize(0) = "png"
ImageSize(1) = BinVal2(oUpFileStream.Read(2))
oUpFileStream.Read(2)
ImageSize(2) = BinVal2(oUpFileStream.Read(2))
Case "464947":
oUpFileStream.Read(3)
ImageSize(0) = "gif"
ImageSize(1) = BinVal(oUpFileStream.Read(2))
ImageSize(2) = BinVal(oUpFileStream.Read(2))
Case "535746":
Dim BinData,sConv,nBits
oUpFileStream.Read(5)
BinData = oUpFileStream.Read(1)
sConv = Num2Str(ASCB(BinData),2 ,8)
nBits = Str2Num(Left(sConv,5),2)
sConv = Mid(sConv,6)
While(Len(sConv)<nBits*4)
BinData = oUpFileStream.Read(1)
sConv = sConv&Num2Str(ASCB(BinData),2 ,8)
Wend
ImageSize(0) = "swf"
ImageSize(1) = Int(ABS(Str2Num(Mid(sConv,1*nBits+1,nBits),2)-Str2Num(Mid(sConv,0*nBits+1,nBits),2))/20)
ImageSize(2) = Int(ABS(Str2Num(Mid(sConv,3*nBits+1,nBits),2)-Str2Num(Mid(sConv,2*nBits+1,nBits),2))/20)
Case "535743":'flashmx
ImageSize(0) = "swf"
ImageSize(1) = 0
ImageSize(2) = 0
Case "FFD8FF":
Dim p1
Do
Do: p1 = BinVal(oUpFileStream.Read(1)): Loop While p1 = 255 And Not oUpFileStream.EOS
If p1>191 and p1<196 Then Exit Do Else oUpFileStream.Read(BinVal2(oUpFileStream.Read(2))-2)
Do:p1 = BinVal(oUpFileStream.Read(1)):Loop While p1<255 And Not oUpFileStream.EOS
Loop While True
oUpFileStream.Read(3)
ImageSize(0) = "jpg"
ImageSize(2) = BinVal2(oUpFileStream.Read(2))
ImageSize(1) = BinVal2(oUpFileStream.Read(2))
Case Else:
If Left(Bin2Str(bFlag),2) = "BM" Then
oUpFileStream.Read(15)
ImageSize(0) = "bmp"
ImageSize(1) = BinVal(oUpFileStream.Read(4))
ImageSize(2) = BinVal(oUpFileStream.Read(4))
Else
ImageSize(0) = "(UNKNOWN)"
End If
End Select
GetImagesize = ImageSize
End Function
End Class
'文件属性类
Class FileInfo_Class
Public FormName,FileName,FilePath,FileSize,FileType,FileStart,FileExt,FileWidth,FileHeight
Private Sub Class_Initialize
FileWidth=0
FileHeight=0
End Sub
'保存文件方法
Public Sub SaveToFile (Byval Path)
Dim Ext,oFileStream
Ext = LCase(Mid(Path, InStrRev(Path, ".") + 1))
If Ext <> FileExt Then Exit Sub
If Trim(Path)="" or FileStart=0 or FileName="" or Right(Path,1)="/" Then Exit Sub
'On Error Resume Next
Set oFileStream = CreateObject ("Adodb.Stream")
oFileStream.Type = 1
oFileStream.Mode = 3
oFileStream.Open
oUpFileStream.Position = FileStart
oUpFileStream.CopyTo oFileStream,FileSize
oFileStream.SaveToFile Path,2
oFileStream.Close
Set oFileStream = Nothing
End Sub
'取得文件数据
Public Function FileData
oUpFileStream.Position = FileStart
FileData = oUpFileStream.Read (FileSize)
End Function
End Class
%>
Ⅲ 请问哈,那能找到个简单的整站ASP源代码,有基本的功能就可以,后台好操作,完整
第一个:
<tr>
<td colspan="2" align="left" valign="top" class="c">留言内容:<p><%=rs("connet")%></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top" class="c" height="16">
..............<a href="del.asp?id=<%=rs("id")%>" style="text-decoration: none"><font color="#333333">删除</font></a>.................<a href="reg.asp" style="text-decoration: none"><font color="#333333">我要留言</font></a>.........</td>
</tr>
把上面的改成
<tr>
<td colspan="3" align="left" valign="top" class="c">留言内容:<p><%=rs("connet")%></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top" class="c" height="16">
..............<a href="del.asp?id=<%=rs("id")%>" style="text-decoration: none"><font color="#333333">删除</font></a>.................<a href="reg.asp" style="text-decoration: none"><font color="#333333">我要留言</font></a>.........</td>
</tr>
第二个:
<!--header begin-->
<%
response.write "<div id=mainbox>"&_
"<table border=0 width=100% cellpadding=4 style=border-collapse: collapse class='top_table'>"&_
"<form name=form11 action=Proct_ListSearch.asp method=get>"&_
" <tr><td colspan=2 height=5></td></tr>"&_
" <tr>"&_
" <td><a href=index.asp title=返回首页><img src=uploadpic/></a></td>"&_
" <td align=right>"&_
" <table><tr><td class=cartimg></td><td><a href=Cart_List.asp>查看我的购物车</a>(<font color=#FF0000>"
if session("y")="" then response.write "0" else response.write session("y")
===================================
response.write "<td><a href=index.asp title=返回首页><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='365' height='53'>"&_
"<param name='movie' value='logo.swf'>"&_
"<param name='quality' value='high'>"&_
"<embed src='logo.swf' width='365' height='53' quality='high' type='application/x-shockwave-flash' width='365' height='53'></embed></object></a></td>"
%>
希望我的回答对你有所帮助。
Ⅳ 下载的asp源码模板怎么使用
怎么使用?这个问题问得有点奇怪
ASP运行,需要服务端,首先确保你电脑有运行ASP的服务端,或者IIS,或者上传至ASP服务空间(最简单的就是有个小ASP服务小软件,你将其放至ASP源码目录下,运行,然后在IE中输入127.0.0.1,既可访问)。
至于使用嘛,不修改,通过你上传的服务IP则可直接使用。
如果要修改,增加改变你自己的东西,则你需要对其进行编辑,编辑方式可以通过网页编辑工具或者记事本(记事本编辑,需要对里面比较熟悉)。
Ⅳ 用ASP写的连接ACCESS数据库网站的源代码
给你提供一个我自己写的吧,三行,从做ASP那天起我就用这三行打遍天下了。希望对你有所参考,网上那些编的连接都是由网络公司出的,有他们的优点,但不够简洁,以下是代码和注释。
<%
Set conn=Server.CreateObject("ADODB.Connection") //创建数据库连接对象 conn
conn.provider="Microsoft.Jet.OLEDB.4.0" //指定数据库驱动类型
conn.Open Server.MapPath("cooshlion.mdb") //打开数据库,请注意与你的数据库位置对应,如果不在当前目录下,请用../相对路径方式
%>
试试吧,将这行代码保存成一个ASP文件,然后建立一个空数据库cooshlion.mdb,再执行一下这个文件,不报错,那就可以了,成功连上,至于关不关闭对象,说老实话,VBScript检测不是那么严格的。
Ⅵ 求asp无限级树型菜单源代码,最好是带数据库的!
关于SELECT的无限联动菜单
index.asp
程序代码:
<html>
<head>
<title></title>
<meta content="text/html; charset=gb2312" http-equiv="content-type">
<style type="text/css"><!--
FONT{font-size:12px}
TD{font-size:12px}
A{color:#333399}
A:hover{color:#FF6600}
--></style>
<script language="Javascript" type="text/Javascript"><!--
function funOnload(){
document.all.list_file.src="jscript_city.asp?base=0&sele=0-&elem=Select01";
}
//pBase级数,以0基,
//pSele是<option 的value值
//pEle是下一级的表单名字
function chgSelect(pBase,pSele,pElem){
//当改变了一个列表之后。清除以后的列表的值。
for(i=parseInt(pElem.replace("Select",""));i<=5;i++){
var tmp="000"+i;
var pElem1=eval("document.Form1.Select"+tmp.substr(tmp.length-2));
pElem1.length=1;
pElem1.selectedIndex=0;
}
//JS用ASP得到数据库的数据来更新下级列表
document.all.list_file.src="jscript_city.asp?base="+pBase+"&sele="+pSele+"&elem="+pElem;
}
//--></script>
<script id="list_file" language="Javascript" type="text/Javascript" src=""></script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="2" text="#333333" onload="funOnload();">
<form name="Form1">
<select name="Select01" onchange="chgSelect(1,this.options[this.selectedIndex].value,'Select02')">
<option value="">省...</option>
</select>
<select name="Select02" onchange="chgSelect(2,this.options[this.selectedIndex].value,'Select03')">
<option value="">市...</option>
</select>
<select name="Select03" onchange="chgSelect(3,this.options[this.selectedIndex].value,'Select04')">
<option value="">县...</option>
</select>
<select name="Select04" onchange="chgSelect(4,this.options[this.selectedIndex].value,'Select05')">
<option value="">乡...</option>
</select>
<select name="Select05">
<option value="">村...</option>
</select>
</form>
</body></html>
'jscript_city.asp
程序代码:
<%
' varBase 下拉菜单等级
' varSele 所选择下拉菜单项的数据库ID
' varElem 下一级的表单名称
varBase=Request.QueryString("base")
varSele=Left(Request.QueryString("sele"),InStr(Request.QueryString("sele"),"-")-1)
varElem=Request.QueryString("elem")
varDistName=""
varAutoID=""
Set conDB=Server.CreateObject("ADODB.CONNECTION")
conDB.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("db1.mdb")
sqlCommand="select * from table1 where filed1="&varBase&" and filed2="&varSele
Set rsRecord=conDB.Execute(sqlCommand)
While Not rsRecord.eof
varDistName=varDistName&chr(34)&rsRecord("filed3")&chr(34)
varAutoID=varAutoID&chr(34)&rsRecord("id")&chr(34)
rsRecord.movenext
If Not rsRecord.Eof Then
varDistName=varDistName&","
varAutoID=varAutoID&","
End If
Wend
Response.Write("var varDistName=new Array("&varDistName&")"&vbcrlf)
Response.Write("var varAutoID=new Array("&varAutoID&")"&vbcrlf)
Response.Write("var varElem=eval("&chr(34)&"document.Form1."&varElem&chr(34)&")"&vbcrlf)
Response.Write("varElem.length=varDistName.length+1;"&vbcrlf)
Response.Write("for(var i=0;i<varDistName.length;i++){"&vbcrlf)
Response.Write(" varElem.options[i+1].text=varDistName;"&vbcrlf)
Response.Write(" varElem.options[i+1].value=varAutoID+'-'+varDistName;"&vbcrlf)
Response.Write("}"&vbcrlf)
Response.Write("varElem.selectedIndex=0;"&vbcrlf)
%>
db1.mdb
'-------------------------------------------------
福建 厦门 思明 黄厝 曾厝桉村
福建 泉州 丰泽 西湖 水头村
如上面的五级转成数据库为:
'-------------------------------
id filed1 filed2 filed3
1 0 0 福建
2 1 1 厦门
3 1 1 泉州
4 2 2 思明
5 3 4 黄厝
6 4 5 曾厝桉村
7 2 3 丰泽
8 3 7 西湖
9 4 8 水头村
'-------------------------------------------------
数据库说明:
id 自动编号
filed1 下拉菜单列表的等级(看级数。可以设置它的精度。是数字类型)
filed2 上一级的id号(用长整型吧)
filed3 这个就不用说了吧(文件。长度自己看情况)
本程序在IIS4+WIN2000P+ACCESS2000下通过。