ASP常见问题及解答(5)

解答|问题

1.'功能: 过虑HTML字符
'输入:字符串
'输出:经格式化后的字符串
function HTMLEncode(fString)
if not isnull(fString) then
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")

fString = Replace(fString, CHR(32)&CHR(32), "  ")
fString = Replace(fString, CHR(9), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
fString = Replace(fString, CHR(10), "<BR> ")

HTMLEncode = fString
end if
end function

2.分页类
'参数:系统(如:product,article),条件(如果是数值,则默认为categoryID的值),排序,
'每页显示记录数,模式(more:显示更多字样,page:显示翻页导航),
'翻页导航模式(number:显示数字,page:显示上一页,下一页),记录显示模版名(显示记录的过程名)
class List
dim p_system'系统表,如tblProduct,tblArticle
dim p_where'条件
dim p_orderBy'排序
dim p_recordCount'每页显示记录数
dim p_horizontal'每行显示记录数
dim p_mode'列表模式,参数:more(更多模式,显示更多字样),page(列表模式,显示翻页导航)
dim p_moreURL'更多模式时的URL
dim p_paginationMode'翻页导航模式,参数:number(数字导航,显示如:1,2,3,4),page(翻页导航,显示如:上一页,下一页)
dim p_models'列表模版过程
dim p_table'列表的table标签
dim p_page'页码
dim p_member'是否显示会员产品
dim p_groupWhere

Private Sub Class_Initialize
p_system=""
p_where=""
p_orderBy=" order by categoryID,orderBy,postdate"
p_recordCount=15
p_horizontal=4
p_mode=""
p_moreURL=""
p_paginationMode="page"
p_models=""
p_table="<table width=100% border=0 align=center cellpadding=0 cellspacing=0 bordercolor=#CCCCCC style='border-collapse: collapse'>"
p_page=1
p_member=false
p_groupWhere="groupID=0"
End Sub

Property Let system(value)
p_system=value
end property
Property Let where(value)
if isInt(value) then
p_where=" where categoryID="&value
else
p_where=" where ("&value&")"
end if
end property
Property Let orderBy(value)
p_orderBy=" order by "&value
end property
Property Let recordCount(value)
p_recordCount=value
end property
Property Let horizontal(value)
p_horizontal=value
end property
Property Let mode(value)
p_mode=value
end property
Property Let moreURL(value)
p_moreURL=value
end property
Property Let paginationMode(value)
p_paginationMode=value
end property
Property Let models(value)
p_models=value
end property
Property Let table(value)
p_table=value
end property
Property Let page(value)
if getNumeric(value)<1 then
p_page=1
else
p_page=int(value)
end if
end property
Property Let member(value)

p_member=value

if p_member then
authorizationID=getValue("tblMember","authorizationID","memberID="&session("memberID"))
if authorizationID="" or authorizationID=0 then
authorizationID=getValue("tblGroup","authorizationID","groupID="&session("groupID"))
end if
virtual=getValue("tblAuthorization","virtual","authorizationID="&authorizationID)
authArr=split(virtual,",")
for i=0 to ubound(authArr)
if i=0 then
p_groupWhere="groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
else
p_groupWhere=p_groupWhere&" or groupID="&getValue("tblGroup","groupID","authorizationID="&authArr(i))
end if
next
else
p_groupWhere="groupID=0"
end if
end property

'列表过程
public sub List()
dim rs
dim where

if p_where="" then
where=" where "&p_groupWhere&" and publish=1"
else
where=p_where&" and ("&p_groupWhere&") and publish=1"
end

时间: 2024-11-02 08:15:36

ASP常见问题及解答(5)的相关文章

ASP常见问题及解答(10)

解答|问题 1.关于<table>折行:<table style="TABLE-LAYOUT: fixed" width="200" border="0" cellspacing="0" cellpadding="7" bgcolor="#f7f7f7"><tr> <td style="LEFT: 0px; WIDTH: 100%; W

ASP常见问题及解答(11)

解答|问题 常用的javascript function//=========================================//输入数据检验//检验空值function funCheckEmpty(m_Text) {var strTmp=m_Textif (strTmp == null || strTmp == "") {return false}return true} //检验内容的长度function funTextLenCheck(m_Text) {var s

ASP常见问题及解答(2)

解答|问题 1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table> 可用于Table 2. <body onselectstart="return false"> 取消选取.防止复制 3. onpaste="return false&q

ASP常见问题及解答(6)

解答|问题 1.防止用户直接访问页面(防止自制表单提交,直接通过链接访问)function checkPrePage()url=request.ServerVariables("HTTP_REFERER")url=trim(replace(url,"http://",""))url=trim(left(url,len(request.ServerVariables("SERVER_NAME"))))if url<>

ASP常见问题及解答(7)

解答|问题 1.分 类:语法应用问题描述:查找两个字符串间的字符出现次数解决办法: function FindStringTimes(strContent,start_string,end_string) 'start_string 与 end_string 之间字符出次的数'written by JaronFindStringTimes = ubound(split(strContent,start_string))end function 示例: 查找以下字符串有多少张图片response.

ASP常见问题及解答(1)

解答|问题 1.如何 最小化.最大化.关闭窗口答:<objectid=hh1classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><paramname="command"value="minimize"></object><objectid=hh2classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a

ASP常见问题及解答(3)

解答|问题 1.图片显示控制:<script language="JavaScript"><!--var flag=false;function DrawImage(ImgD){ var image=new Image(); image.src=ImgD.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= 360/270)

ASP常见问题及解答(8)

解答|问题 1.表格排序表格排序是对表格而言的,与表格的生成无关.就是说,无论用何种方式产生的表格排序时都一样.这是排序函数,很简单.分升序和降序,要求传入参数:obj 表格名或id; n 排序列,第一列为0<script>function table_sort_asc(obj,n) { var i,j; var tab = eval("document.all."+obj); if(tab.tagName != "TABLE") return; for

ASP常见问题及解答(9)

解答|问题 1.[打开]命令的实现 [格式]:document.execCommand("open") [说明]这跟VB等编程设计中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨. [举例]在<body></body>之间加入: <a href="#" onclick=document.execCommand("open")>打开</a> 2.[使用 记事本 编辑]命令的实现 [格

ASP常见问题及解答(4)

解答|问题 1.取当前网页的地址全名,以便返回用<%Function GetUrl() On Error Resume Next Dim strTempIf LCase(Request.ServerVariables("HTTPS")) = "off" ThenstrTemp = "http://"ElsestrTemp = "https://" End If strTemp = strTemp & Reques