六、Server对象
1.HTMLEncode方法
对特定的字符串进行HTML编码,如你本来要显示下列内容:
The Underline tag(<u></u>) is used to underline the surrounded text.
但很可能实际显示成:
The Underline tag() is used to underline the surrounded text.
为了避免这种情况,可以调用Server对象的HTMLEncode方法,如:
<%
Response.Write Server.HTMLEncode("The Underline tag(<U></U>) is used to underline the surrounded text.")
%>
2.URLEncode方法
根据URL规则对字符串进行编码。当字符串数据以URL格式传递到服务器时,串中间不能有空格,不能有特殊字符,这时,你就必须用URL编码。
3.CreateObject方法
用于创建已注册到服务器机器上的ActiveX组件例程,这恐怕是最重要的一个方法了:
句法如下:
Server.CreateObject("ComponentName")
可以作为例程启动的组件可以是ActiveX能够使用的所有内置组件,实际上是存在于服务器上的任何ActiveX组件。比如,要使用金融计算,步骤如下:
1.创建对象
<%
set x=server.createobject("extend.financial");
%>
2.调用对象的方法
<%
set x=server.createobject("extend.financial")
response.write Format(x.futval(.07/12,200,-500),"###,###,##0.00")
%>
3.释放例程
<%
set x=Nothing
%>