<%
'if DB3NF is referenced in global.asa all these constants are not needed:
const opValue=0
const opDisplayName=1
const odMaxValueLength=8000
dim IE
IE=(instr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MSIE")>0)
sub DisplayPropEdit(Prop)
DisplayPropEditShow Prop, Prop.Schema.DisplayTypeEdit
end sub
sub DisplayPropShow(Prop)
DisplayPropEditShow Prop, Prop.Schema.DisplayTypeShow
end sub
function IIF(Expression, TruePart, FalsePart)
if Expression>"" then
if cbool(Expression) then
IIF=TruePart
else
IIF=FalsePart
end if
else
IIF=FalsePart
end if
end function
sub DisplayPropEditShow(Prop, DisplayType)
dim opt, PropValue, temp, i
If Prop.Schema.OptionList>"" and DisplayType<>"dropdown" and DisplayType<>"radio" and Prop.Value>"" then
Opt=objSchema.OptionValues(Prop.Schema.OptionList)
for i=0 to ubound(Opt, 2)
if Opt(opValue,i) = Prop.Value then
PropValue = Opt(opDisplayName,i)
exit for
end if
next
else
PropValue = IIF(Isnull(Prop.Value), "", Prop.Value)
PropValue = Replace(PropValue, """", """)
end if
select case DisplayType
case "normaltext"
Response.Write "<span class=normaltext>"
if Prop.Schema.DataType = vbBoolean then
if Prop.Value then
Response.Write "Yes"
else
Response.Write "No"
end if
else
Response.Write Server.HTMLEncode(PropValue)
end if
if Prop.Value>"" then
'nothing
else
Response.Write " "
end if
Response.Write "</span>"
case "textbox"
Response.Write "<input " & IIF(IE, "class=PropertyTableTD ", "") & "type=text " & FormPropName(Prop) & " value=""" & PropValue & """ size=" & IIF(IE, 50, 25) & MaxLength(Prop) & ">"
case "smalltextbox"
Response.Write "<input " & IIF(IE, "class=PropertyTableTD ", "") & "type=text " & FormPropName(Prop) & " value=""" & PropValue & """ size=8" & MaxLength(Prop) & ">"
case "checkbox"
temp = FormPropName(Prop)
Response.Write "<input type=checkbox " & temp & CheckBoxChecked(Prop) & "><input type=hidden " & temp & " value=0>"
case "dropdown"
Response.Write "<SELECT class=PropertyTableTD " & FormPropName(Prop) & ">"
Opt=objSchema.OptionValues(Prop.Schema.OptionList)
for i=0 to ubound(Opt, 2)
Response.Write "<OPTION value='" & Opt(opValue,i) & "' " & CheckSelected(Prop, Opt(opValue,i)) & ">" & Opt(opDisplayName,i) & "</OPTION>"
next
Response.Write "</SELECT>"
case "heading1"
Response.Write "<H1>" & Server.HTMLEncode(PropValue) & "</H1>"
case "heading2"
Response.Write "<H2>" & Server.HTMLEncode(PropValue) & "</H2>"
case "heading3"
Response.Write "<H3>" & Server.HTMLEncode(PropValue) & "</H3>"
case "password"
Response.Write "<input " & IIF(IE, "class=PropertyTableTD ", "") & "type=password " & FormPropName(Prop) & " value=""" & PropValue & """ size=" & IIF(IE, 50, 25) & MaxLength(Prop) & ">"
case "passwordshow"
Response.Write string(len(PropValue), "*")
case "hidden"
Response.Write "<input type=hidden " & FormPropName(Prop) & " value=""" & Prop.Value & """>"
case "italic"
Response.Write "<i>" & Server.HTMLEncode(PropValue) & "</i>"
case "radio"
if Prop.Schema.DataType = vbBoolean then
temp = FormPropName(Prop)
Response.Write "<INPUT type=radio " & temp & " value=1" & IIf(PropValue, " checked", "") & ">Yes</INPUT> "
Response.Write "<INPUT type=radio " & temp & " value=0" & IIf(PropValue, "", " checked") & ">No</INPUT>"
else
Opt=objSchema.OptionValues(Prop.Schema.OptionList)
temp=FormPropName(Prop)
for i=0 to ubound(Opt, 2)
Response.Write "<INPUT type=radio " & tep & " value=" & Opt(opValue,i) & CheckRadioChecked(Prop, Opt(opValue,i)) & " id=radio1 name=radio1>" & Opt(opDisplayName,i) & "</INPUT>"
next
end if
case "textarea"
Response.Write "<textarea class=PropertyTableTD rows=6 cols=" & IIF(IE, 50, 25) & " " & FormPropName(Prop) & ">" & PropValue & "</textarea>"
case "fileyesno"
if PropValue>"" then
Response.Write "<a target=""viewfile"" href=""" & PropValue & """>View/Download</a>"
else
Response.Write "No file"
end if
case "fileupload"
Response.Write "<input type=file size=" & IIF(IE, 16, 10) & " " & FormPropName(Prop) & ">"
if PropValue>"" then
Response.Write " <a target=""viewfile"" href=""" & PropValue & """>View/Download</a>"
else
Response.Write " No file yet"
end if
end select
end sub
function FormPropName(Prop)
dim PropKey
PropKey = Prop.FormKey
FormPropName = "name=" & PropKey & " id=" & PropKey
end function
function MaxLength(Prop)
dim res
select case Prop.Schema.DataType
case vbString
if not isnull(Prop.Schema.Max) then
res = Prop.Schema.Max
else
res = odMaxValueLength
end if
case vbDate
res =16
case else
res =10
end select
MaxLength = " MaxLength=" & res
end function
Function CheckBoxChecked(Prop)
if not isnull(Prop.Value) then if cbool(Prop.Value) then CheckBoxChecked = " checked"
end function
Function CheckSelected(Prop, OptValue)
if Prop.Value = OptValue and OptValue>"" then CheckSelected = " selected"
end function
Function CheckRadioChecked(Prop, OptValue)
if Prop.Value = OptValue and OptValue>"" then CheckRadioChecked = " checked"
end function
sub Display(Prop, showedit)
if Prop.Separator>"" then PrintSeparator Prop.Separator
Response.Write "<tr><td class=PropertyTableTD width=250>"
if Prop.Schema.Description="" then
Response.Write Prop.Schema.DisplayName & ":"
else
Response.Write "<a href=""javascript:none()"" onclick=""helpp('"
Response.Write Prop.Schema.Description
Response.Write "')"" onmouseout=""help_d()"" onmouseover=""top.status='click for help';return true"">"
Response.Write Prop.Schema.DisplayName & "</a>:"
end if
Response.Write "</td><td class=PropertyTableTD width=300>"
if ( showedit ) then ' show
DisplayPropShow Prop
else
DisplayPropEdit Prop
if Prop.Required then
DisplayRequired
end if
end if
Response.Write "</td></tr>"
if Prop.ErrorMessage>"" then
DisplayErrorMessage(Prop.ErrorMessage)
end if
end sub
Sub PrintSeparator(Separator)
Response.Write "<tr><td colspan=2 class=Separator><font size=1><br></font>" & Separator & "</td></tr>"
end sub
sub DisplayRequired
Response.Write "<font size=4 color=red> *</font>"
end sub
sub DisplayErrorMessage(eMsg)
Response.Write "<tr><td Xclass=ErrMsg> </td><td class=ErrMsg>"
Response.Write eMsg 'Prop.ErrorMessage
Response.Write "</td></tr>"
end sub
%>