asp.net(C#) Xml操作(增删改查)练习
2024-07-10 12:39:12
供稿:网友
web.config配置:
代码如下:
<appSettings>
<add key="xmlFile" value="xml/class.xml"/>
</appSettings>
<appSettings>
<add key="xmlFile" value="xml/class.xml"/>
</appSettings>
前台:
代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="test_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>C#操作Xml(增删改查)练习</title>
</head>
<body>
<form id="form1" runat="server">
<div id="showXml" runat="server">
显示Xml文档
</div>
<div style="background-color:Green;color:Yellow;" style="background-color:Green;color:Yellow;">为html控件绑定服务器控件的两个要点:<br />
1.onserverclick="serverMethod"这里只写方法名.<br />
2.后台代码,必须是<br />
protected void XmlAdd(object sender, EventArgs e){}<br />
注意两个参数及保护级.
</div>
<input id="btnAdd" type="button" value="add" runat="server" onserverclick="XmlAdd" />
<input id="btnDelete" type="button" value="delete" runat="server" onserverclick="XmlDelete" />
<input id="btnUpdate" type="button" value="update" runat="server" onserverclick="XmlUpdate" />
<input id="btnQuery" type="button" value="query" runat="server" onserverclick="XmlQuery" />
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="test_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>C#操作Xml(增删改查)练习</title>
</head>
<body>
<form id="form1" runat="server">
<div id="showXml" runat="server">
显示Xml文档
</div>
<div style="background-color:Green;color:Yellow;" style="background-color:Green;color:Yellow;">为html控件绑定服务器控件的两个要点:<br />
1.onserverclick="serverMethod"这里只写方法名.<br />
2.后台代码,必须是<br />
protected void XmlAdd(object sender, EventArgs e){}<br />
注意两个参数及保护级.
</div>
<input id="btnAdd" type="button" value="add" runat="server" onserverclick="XmlAdd" />
<input id="btnDelete" type="button" value="delete" runat="server" onserverclick="XmlDelete" />
<input id="btnUpdate" type="button" value="update" runat="server" onserverclick="XmlUpdate" />
<input id="btnQuery" type="button" value="query" runat="server" onserverclick="XmlQuery" />
</form>
</body>