欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP+XML實(shí)例演練編程代碼

 更新時(shí)間:2007年11月24日 22:01:17   作者:  

  五、程序首頁(default.asp) 

  調(diào)用相應(yīng)的包含文件和公共函數(shù),格式化XML文件,并進(jìn)行顯示??梢钥吹?,頁面Title是可定制的,公共的頭部和尾部都做成了相應(yīng)的包含文件。C_TITLE、C_XMLFILE和C_XSLFILE為公共常量,在constpub.asp文件中定義,至于它們的意義,相信讀者可以很容易地明白。這里調(diào)用了上面定義的FormatXml函數(shù)。 
<% Option Explicit 
'*********************************************** 
' 說明:通訊錄 
' 作者:gwd 2002-11-05 
'*********************************************** 
%> 
<!--#include file="pub/funcxml.asp"--> 
<!--#include file="pub/constpub.asp"--> 
<HTML> 
<HEAD> 
<TITLE><% = C_TITLE %></TITLE> 
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=GB2312"/> 
<link rel="stylesheet" href="contact.css" type="text/css"> 
</HEAD> 
<BODY> 
<!--#include file="pub/header.asp"--> 
<% = FormatXml(C_XMLFILE, C_XSLFILE) %> 
<br> 
<!--#include file="pub/footer.asp"--> 
</BODY> 
</HTML> 
  六、添加、修改和刪除XML中的信息 

  我們知道,在Cls_Person中已經(jīng)定義了相應(yīng)的方法,因此,在各個(gè)文件中,只需要調(diào)用對(duì)應(yīng)的方法即可。添加信息的文件為add.asp,修改信息的文件為edit.asp,刪除信息的文件為delete.asp,我們僅以add.asp文件為例進(jìn)行說明。其中的CheckStrInput和CheckStrOutput函數(shù),用來格式化用戶的輸入和輸出字符串。 
<% Option Explicit 
'*********************************************** 
' 說明:37080308通訊錄 
' 作者:gwd 2002-11-05 
'*********************************************** 
%> 
<!--#include file="pub/funcxml.asp"--> 
<!--#include file="pub/constpub.asp"--> 
<!--#include file="pub/funcpub.asp"--> 
<!--#include file="pub/class/clsPerson.asp"--> 
<% 
 Dim objXml, objPerson 
 Dim strErr 
 Set objXml = Server.CreateObject("MSXML2.DOMDocument") 
 Set objPerson = New Cls_Person ' 生成Cls_Person對(duì)象 
 If Request.Form("btnOk") <> "" Then 
  If LoadXmlDoc(objXml, C_XMLFILE, False, strErr) Then ' 裝載XML文件 
   ' 給相應(yīng)的屬性賦值 
   objPerson.Name = CheckStrInput(Request.Form("txtName")) 
   objPerson.Nick = CheckStrInput(Request.Form("txtNick")) 
   objPerson.Mobile = CheckStrInput(Request.Form("txtMobile")) 
   objPerson.Tel = CheckStrInput(Request.Form("txtTel")) 
   objPerson.Email = CheckStrInput(Request.Form("txtEmail")) 
   objPerson.QQ = CheckStrInput(Request.Form("txtQQ")) 
   objPerson.Company = CheckStrInput(Request.Form("txtCompany")) 
   If Not objPerson.AddToXml(objXml) Then ' 調(diào)用Cls_Person類的AddToXml方法,添加數(shù)據(jù) 
    AddErr strErr, objPerson.GetLastError 
   Else 
    AddErr strErr, "添加成功" 
    Response.Write "<script language=""javascript"">opener.location.reload();</script>" 
   End If 
  End If 
 End If 
 Set objXml = Nothing 
%> 
<HTML> 
<HEAD> 
<TITLE><% = C_TITLE %></TITLE> 
<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=GB2312"/> 
<link rel="stylesheet" href="contact.css" type="text/css"> 
<script language="javascript"> 
<!-- 
function CheckForm() 

 return true; 

//--> 
</script> 
</HEAD> 
<BODY> 
<% = strErr %> 
<div class="title">添加聯(lián)系信息</div> 
<form name="form1" method="post" action="add.asp" onsubmit="return CheckForm()"> 
?。紅able align="center" width="100%" cellspacing="1" cellpadding="2" border="0" bgcolor="#666600"> 
  <tr bgcolor="#ffffff"> 
  ?。紅d width="25%" bgcolor="#e5e5e5" align="right"><b>姓名:</b></td> 
   <td width="75%"><input type="text" name="txtName" size="25" class="input" value="<%=CheckStrOutput(objPerson.Name)%>"></td> 
 ?。?tr> 
 ?。紅r bgcolor="#ffffff"> 
  ?。紅d bgcolor="#e5e5e5" align="right"><b>英文名:</b></td> 
  ?。紅d><input type="text" name="txtNick" size="25" class="input" value="<%=CheckStrOutput(objPerson.Nick)%>"></td> 
 ?。?tr> 
 ?。紅r bgcolor="#ffffff"> 
   <td bgcolor="#e5e5e5" align="right"><b>手機(jī):</b></td> 
  ?。紅d><input type="text" name="txtMobile" size="25" class="input" value="<%=CheckStrOutput(objPerson.Mobile)%>"></td> 
  </tr> 
  <tr bgcolor="#ffffff"> 
  ?。紅d bgcolor="#e5e5e5" align="right"><b>電話:</b></td> 
  ?。紅d><input type="text" name="txtTel" size="25" class="input" value="<%=CheckStrOutput(objPerson.Tel)%>"></td> 
 ?。?tr> 
  <tr bgcolor="#ffffff"> 
  ?。紅d bgcolor="#e5e5e5" align="right"><b>Email:</b></td> 
  ?。紅d><input type="text" name="txtEmail" size="25" class="input" value="<%=CheckStrOutput(objPerson.Email)%>"></td> 
  </tr> 
 ?。紅r bgcolor="#ffffff"> 
  ?。紅d bgcolor="#e5e5e5" align="right"><b>QQ:</b></td> 
  ?。紅d><input type="text" name="txtQQ" size="25" class="input" value="<%=CheckStrOutput(objPerson.QQ)%>"></td> 
 ?。?tr> 
 ?。紅r bgcolor="#ffffff"> 
  ?。紅d bgcolor="#e5e5e5" align="right"><b>所在公司:</b></td> 
  ?。紅d><input type="text" name="txtCompany" size="25" class="input" value="<%=CheckStrOutput(objPerson.Company)%>"></td> 
 ?。?tr> 
?。?table> 
?。糱r> 
?。糳iv align="center"> 
?。糹nput type="submit" name="btnOk" value="提交"> 
?。糹nput type="button" name="btnClose" value="關(guān)閉" onclick="javascript:return window.close();"> 
?。?div> 
</form> 
</BODY> 
</HTML> 
<% 
Set objPerson = Nothing 
%> 
  七、總結(jié) 

  到此,我們的聯(lián)系信息管理程序就大功告成了。怎么樣,感覺如何,應(yīng)該來說還是相當(dāng)簡單的吧。當(dāng)然了,這個(gè)例程還有許多可以改進(jìn)的地方,我這里也只不過是拋磚引玉,希望讀者在掌握了XML編程之后,自行修改完善吧。 

  此例程已經(jīng)在我本機(jī)(Windows Server 2000、IIS5.0和IE6.0)和網(wǎng)上進(jìn)行了測(cè)試,都能夠正常運(yùn)行。 

相關(guān)文章

最新評(píng)論