Copy codeThe Code is as follows: <%
Rem article title: css buttons using the vbs class
Rem Author: yanek
Rem contact: aspboy@263.net
Class CssButton
Public Name
Public BackColor
Public BorderColor
Public Font
Public FontColor
Public Width
Public Text
Public Url
Public MouseOverColor
Public Function GenerateStyleTag ()
'Create the STYLE tag
Dim strStyle
StrStyle = "<style type =" "text/css" ">" & vbCrLf &_
"<! -- "& VbCrLf &_
"# Mybutton" & Name & "{border-style: inset;" & vbCrLf &_
"Border-color:" & BorderColor & ";" & vbCrLf &_
"Background-color:" & BackColor & ";" & vbCrLf &_
"Width:" & Width & ";" & vbCrLf &_
"Text-align: center;}" & vbCrLf &_
"A. buttontext" & Name & "{color:" & FontColor & ";" & vbCrLf &_
"Text-decoration: none;" & vbCrLf &_
"Font:" & Font & ";" & vbCrLf &_
"Cursor: hand;}" & vbCrLf &_
". Buttonover" & Name & "{color:" & MouseOverColor & ";" & vbCrLf &_
"Text-decoration: none;" & vbCrLf &_
"Font:" & Font & ";" & vbCrLf &_
"Cursor: hand;}" & vbCrLf &_
"// -->" & VbCrLf &_
"</STYLE>"
GenerateStyleTag = strStyle
End Function
Public Function GenerateButtonTag ()
Dim strHTML
StrHTML = "<a href =" & Url & "class =" "buttontext" & Name &""""&_
"OnMouseOver =" "this. className = 'buttonover" & Name &"';"""&_
"OnMouseOut =" "this. className = 'buttontext" & Name & "';" "> "&_
VbCrLf & "<div id =" "mybutton" & Name & ""> "& vbCrLf & Text & vbCrLf &" </div> </a> "& vbCrLf
GenerateButtonTag = strHTML
End Function
End Class
Rem creates a class instance
Dim btnYahoo, btnLycos
Set btnYahoo = New CssButton
Set btnLycos = New CssButton
Rem sets the properties of the button object
BtnYahoo. BackColor = "# aaaaaa"
BtnYahoo. BorderColor = "# bbbbbbbb"
BtnYahoo. Font = "bold 12pt Verdana"
BtnYahoo. FontColor = "black"
BtnYahoo. Width = "80px"
BtnYahoo. MouseOverColor = "yellow"
BtnYahoo. Url = "http://www.yahoo.com /"
BtnYahoo. Name = "yahoo"
BtnYahoo. Text = "Yahoo! "
Rem call method output button
Response. Write btnYahoo. GenerateStyleTag ()
Response. Write btnYahoo. GenerateButtonTag ()
Response. Write "<p> </p>"
Rem sets the properties of the button object
BtnLycos. BackColor = "# aaaaaa"
BtnLycos. BorderColor = "# bbbbbbbb"
BtnLycos. Font = "10pt Arial"
BtnLycos. FontColor = "black"
BtnLycos. Width = "70px"
BtnLycos. MouseOverColor = "yellow"
BtnLycos. Url = "http://www.lycos.com /"
BtnLycos. Name = "lycos"
BtnLycos. Text = "Lycos"
Rem call method output button
Response. Write btnLycos. GenerateStyleTag ()
Response. Write btnLycos. GenerateButtonTag ()
%>
Demo: http://www.cnaspol.com/vbsclasscssbutton.asp