servercontrol.asp

来自「ASPSQL企业网络管理系统」· ASP 代码 · 共 52 行

ASP
52
字号
<%
class DBCombo
	private props,optsV,optsL
	public Name,Selected
	private sub class_initialize
	  props = ""
		optsV = null
	end sub
	private sub class_terminate
	  '
	end sub
	public property let Properties(sProp)
	  props = sProp
	end property
	public property get Properties()
	  Properties = props
	end property
	public sub setOptions(arrV,arrL)
	  optsV = arrV
	  optsL = arrL
	end sub
	public sub WriteHTML(sql,conn)
		Response.Write "<select id=""sel_" & Name & """ name=""" & Name & """ "
		Response.Write Properties & ">"
	  if sql <> "" then
			dim rstmptmp,i
			set rstmp = Server.CreateObject("ADODB.RECORDSET")
			rstmp.Open sql,conn 
			while not rstmp.EOF
				if rstmp(0) = Selected then
					Response.Write "<option value=""" & trim(rstmp(0)) & """ selected>" & trim(rstmp(1)) & "</option>"
				else
					Response.Write "<option value=""" & trim(rstmp(0)) & """>" & trim(rstmp(1)) & "</option>"
				end if
				rstmp.MoveNext
			wend
			rstmp.Close
			set rstmp=nothing
		end if
		if not isnull(optsV) then
			for i = 0 to UBound(optsV)
				if optsV(i) = Selected then
					Response.Write "<option value=""" & optsV(i) & """ selected>" & optsL(i) & "</option>"
				else
					Response.Write "<option value=""" & optsV(i) & """>" & optsL(i) & "</option>"
				end if
			next
		end if
		Response.Write "</select>"
	end sub
end class
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?