Ajax
For a long time did not write ASP, this time to write a message board really feel a little difficult, the competition has written a whole day, haha.
There is nothing else to write, the use of three-layer structure (do not know, the original three-layer concept is very confused)
Demo of the message board, I hope you big sister if found there is a loophole please tell me here, do not black my website, where the younger brother first thanked.
Index.asp
<% @codepage =65001%>
<%
OptionExplicit
%>
<%response.charset= "Utf-8"%>
<%Session.CodePage=65001%>
<!--#includefile = "acchelper.asp"-->
<!--#includefile = "common.asp"-->
<!--#includefile = "dal_guest.asp"-->
<!--#includefile = "mod_guest.asp"-->
<!--#includefile = "bll_guest.asp"-->
<%
Dimmybll
Dimmylist
Setmybll=newbll_guest
Selectcaserequest ("Tcmd")
Case "SAVE"
Mybll. Insert ()
Case "DEL"
Mybll. Delete ()
Endselect
Mylist=mybll. Findbypage ()
%>
<p>
<formname= "Subform" id= "Subform" >
<textareaid= "Con" name= "con" cols= "rows=" "6" wrap= "VIRTUAL" ></textarea>
<inputtype= "button" name= "Submit" value= "submit Message" onclick= "$ (' guest/index.asp?tcmd=save&content= ' +escape ( this.form.con.value)) "/>
</form>
</p>
<%=myList%>
Bll_guest.asp
<%
'///<summary>
'///Summary description.
'///</summary>
Classbll_guest
Privatemycom,mymod,mydal
Privateli,ul
Privatedel
' Get information
Publicsubgetguest ()
Mydal. Getguest (ID)
Endsub
' New information
Publicsubinsert ()
Mymod. Content=request ("content")
Mymod.re=request ("Re")
Mymod. Addtime=now ()
Mymod. Ip=request.servervariables ("Http_x_forwarded_for")
Iflen (Mymod. IP) <=0thenmymod.ip=request.servervariables ("REMOTE_ADDR")
Callmydal.insert (Mymod)
Endsub
' Update information
Publicsubupdate ()
Callmydal.update (Mymod)
Endsub
' Delete Information
Publicsubdelete ()
Mydal. Delete (Request ("Id")
Endsub
' Find information
Publicfunctionfindbypage ()
Dimpagesize,currentpage,wherevalue,ordervalue,recordcount
Dimobjrs
Dimtmp1,tmp2,tmp3,parms,i
Dimtcmd
Tcmd=request ("Tcmd")
Pagesize= "8"
Currentpage=request ("PageNo")
Iflen (currentpage) <=0then
Currentpage=1
EndIf
Wherevalue= ""
Ordervalue= "Id"
Setobjrs=mydal. Findbypage (Pagesize,currentpage-1,wherevalue,ordervalue)
I=1
Recordcount=mydal. Count (Wherevalue)
Dowhilenotobjrs.eof
Iftcmd= "DEL" Then
Del= "<ahref=" "Tcmd=del&id=" &objrs ("Id") & "" > Delete </a>
Else
Del= ""
EndIf
Parms=array (I,objrs ("content"), objRS ("IP"), objRS ("Addtime"), DEL)
Tmp1=tmp1&mycom. Format (li,parms)
Objrs.movenext
I=i+1
Loop
Tmp3=mycom. Page (Pagesize,currentpage,recordcount, "guest/index.asp?tcmd=list")
Parms=array (Tmp1,tmp3)
Tmp2=tmp2&mycom. Format (ul,parms)
Findbypage=tmp2
Endfunction
Privatesubclass_initialize ()
Li= "<li><span>{0}</span><span>{1}</span><br/><span> Author: {2}</span ><span>{3}</span><span>{4}</span></li> "&vbcrlf
Ul= "<UL>{0}<li>{1}</li></UL>"
Del= ""
Setmycom=newcommon
Setmymod=newmod_guest
Setmydal=newdal_guest
Endsub
Privatesubclass_terminate ()
Setmycom=nothing
Setmymod=nothing
Setmydal=nothing
Endsub
Endclass
%>
Dal_guest.asp
<%
'///<summary>
'///Summary description.
'///</summary>
Classdal_guest
Privatesql_01
Privatesql_02
Privatesql_03
Privatesql_04
Privatesql_05