Cls_Fun.asp
上传用户:prospercnc
上传日期:2019-12-08
资源大小:1314k
文件大小:8k
- <%
- '==========================================
- '文 件 名:Cls_Fun.asp
- '文件用途:常规函数类
- '版权所有:方卡在线
- '==========================================
- Class Cls_Fun
- Private x,y,ii
- '==============================
- '函 数 名:AlertInfo
- '作 用:错误显示函数
- '参 数:错误提示内容InfoStr,转向页面GoUrl
- '==============================
- Public Function AlertInfo(InfoStr,GoUrl)
- If GoUrl="1" Then
- Response.Write "<Script>alert('"& InfoStr &"');location.href='javascript:history.go(-1)';</Script>"
- Else
- Response.Write "<Script>alert('"& InfoStr &"');location.href='"& GoUrl &"';</Script>"
- End If
- Response.End()
- End Function
-
- '==============================
- '函 数 名:HTMLEncode
- '作 用:字符转换函数
- '参 数:需要转换的文本fString
- '==============================
- Public Function HTMLEncode(fString)
- If Not IsNull(fString) Then
- fString = replace(fString, ">", ">")
- fString = replace(fString, "<", "<")
- fString = Replace(fString, CHR(32), " ")
- fString = Replace(fString, CHR(34), """)
- fString = Replace(fString, CHR(39), "'")
- fString = Replace(fString, CHR(9), " ")
- 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
-
- '==============================
- '函 数 名:HTMLDncode
- '作 用:字符转回函数
- '参 数:需要转换的文本fString
- '==============================
- Public Function HTMLDncode(fString)
- If Not IsNull(fString) Then
- fString = Replace(fString, ">",">" )
- fString = Replace(fString, "<", "<")
- fString = Replace(fString, " ", 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, "<p></p>",CHR(10) & CHR(10) )
- fString = Replace(fString, "<br />",CHR(10) )
- HTMLDncode = fString
- End If
- End Function
-
- '==============================
- '函 数 名:AlertNum
- '作 用:判断是否是数字(验证字符,不为数字时的提示)
- '参 数:需进行判断的文本CheckStr,错误提示ErrStr
- '==============================
- Public Function AlertNum(CheckStr,ErrStr)
- If Not IsNumeric(CheckStr) Or CheckStr="" Then
- Call AlertInfo(ErrStr,"1")
- End If
- End Function
- '==============================
- '函 数 名:AlertString
- '作 用:判断字符串长度
- '参 数:
- '需进行判断的文本CheckStr
- '限定最短ShortLen
- '限定最长LongLen
- '验证类型CheckType(0两头限制,1限制最短,2限制最长)
- '过短提示LongStr
- '过长提示LongStr,
- '==============================
- Public Function AlertString(CheckStr,ShortLen,LongLen,CheckType,ShortErr,LongErr)
- If (CheckType=0 Or CheckType=1) And StringLength(CheckStr)<ShortLen Then
- Call AlertInfo(ShortErr,"1")
- End If
- If (CheckType=0 Or CheckType=2) And StringLength(CheckStr)>LongLen Then
- Call AlertInfo(LongErr,"1")
- End If
- End Function
-
- '==============================
- '函 数 名:ShowNum
- '作 用:判断是否是数字(验证字符,不为数字时的提示)
- '参 数:需进行判断的文本CheckStr,错误提示ErrStr
- '==============================
- Public Function ShowNum(CheckStr,ErrStr)
- If Not IsNumeric(CheckStr) or CheckStr="" Then
- Response.Write(ErrStr)
- Response.End()
- End If
- End Function
- '==============================
- '函 数 名:ShowString
- '作 用:判断字符串长度
- '参 数:
- '需进行判断的文本CheckStr
- '限定最短ShortLen
- '限定最长LongLen
- '验证类型CheckType(0两头限制,1限制最短,2限制最长)
- '过短提示LongStr
- '过长提示LongStr,
- '==============================
- Public Function ShowString(CheckStr,ShortLen,LongLen,CheckType,ShortErr,LongErr)
- If (CheckType=0 Or CheckType=1) And StringLength(CheckStr)<ShortLen Then
- Response.Write(ShortErr)
- Response.End()
- End If
- If (CheckType=0 Or CheckType=2) And StringLength(CheckStr)>LongLen Then
- Response.Write(LongErr)
- Response.End()
- End If
- End Function
-
- '==============================
- '函 数 名:StringLength
- '作 用:判断字符串长度
- '参 数:需进行判断的文本Txt
- '==============================
- Private Function StringLength(Txt)
- Txt=Trim(Txt)
- x=Len(Txt)
- y=0
- For ii = 1 To x
- If Asc(Mid(Txt,ii,1))<=2 or Asc(Mid(Txt,ii,1))>255 Then
- y=y + 2
- Else
- y=y + 1
- End If
- Next
- StringLength=y
- End Function
-
- '==============================
- '函 数 名:BeSelect
- '作 用:判断select选项选中
- '参 数:Select1,Select2
- '==============================
- Public Function BeSelect(Select1,Select2)
- If Select1=Select2 Then
- BeSelect=" selected='selected'"
- End If
- End Function
-
- '==============================
- '函 数 名:BeCheck
- '作 用:判断Check选项选中
- '参 数:Check1,Check2
- '==============================
- Public Function BeCheck(Check1,Check2)
- If Check1=Check2 Then
- BeCheck=" checked='checked'"
- End If
- End Function
-
- '==============================
- '函 数 名:ShowPageCode
- '作 用:显示页码
- '参 数:链接PageUrl,当前页Nows,记录数AllCount,每页数量Sizes,总页数AllPage
- '==============================
- Public Function ShowPageCode(PageUrl,Nows,AllCount,Sizes,AllPage)
- If Nows>1 Then
- Response.Write("<a href=""javascript:void(0);"" onclick=""SetRContent('MainRight','"&PageUrl&"1');"">第一页</a>")
- Response.Write(" ")
- Response.Write("<a href=""javascript:void(0);"" onclick=""SetRContent('MainRight','"&PageUrl&(Nows-1)&"');"">上一页</a>")
- Else
- Response.Write("第一页")
- Response.Write(" ")
- Response.Write("上一页")
- End If
- Response.Write(" ")
- If AllPage>Nows Then
- Response.Write("<a href=""javascript:void(0);"" onclick=""SetRContent('MainRight','"&PageUrl&(Nows+1)&"');"">下一页</a>")
- Response.Write(" ")
- Response.Write("<a href=""javascript:void(0);"" onclick=""SetRContent('MainRight','"&PageUrl&AllPage&"');"">尾页</a>")
- Else
- Response.Write("下一页")
- Response.Write(" ")
- Response.Write("尾页")
- End If
- Response.Write(" "&Sizes&"条/页 共"&AllPage&"页/"&AllCount&"条 当前第"&Nows&"页 ")
- Response.Write("<select name=""Change_Page"" id=""Change_Page"" onChange=""SetRContent('MainRight','"&PageUrl&"'+this.options[this.selectedIndex].value);"">")
- For i=1 To AllPage
- If i=Nows Then
- Response.Write("<option value="""&i&""" selected=""selected"">第"&i&"页</option>")
- Else
- Response.Write("<option value="""&i&""">第"&i&"页</option>")
- End If
- Next
- Response.Write("</select>")
- End Function
- '==============================
- '函 数 名:GetNowUrl
- '作 用:返回当前网址
- '参 数:
- '==============================
- Public Function GetNowUrl()
- GetNowUrl=Request.ServerVariables("Script_Name")&"?"&Request.ServerVariables("QUERY_STRING")
- End Function
-
- '==============================
- '函 数 名:SelectCategory
- '作 用:判断问题类型
- '参 数:要判断的类型QuestionType
- '==============================
- Public Function SelectCategory(QuestionType)
- Select Case QuestionType
- Case 0
- SelectCategory="单选题"
- Case 1
- SelectCategory="多选题"
- Case 2
- SelectCategory="简答题"
- End Select
- End Function
- End Class
- %>