ASP Simple AJAX Message Board

Source: Internet
Author: User
Tags insert servervariables
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.