动态修改web.config文件里面的配置节
但还有个问题,
我没有做到修改SYSTEM。WEB
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ import namespace="system.data"%>
<%@ import namespace="system.io"%>
<script runat="server">
sub page_load(s as object,e as eventargs)

if request.QueryString("action")="editok" then
dim n as integer
dim ds as new dataset()
ds.readxml(server.MapPath("web.CONFIG"))
for n=0 to ds.tables(1).rows.count-1
ds.tables(1).rows(n)(1) = request.Form("s"& n)
next
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("web.config"))
ds.Clear()
ds.Dispose()
response.Write("<script>alert('修改成功');location.href='?';</sc"&"ript>")
else
if file.exists(server.mappath("Web.config"))=FALSE THEN
response.write("当前目录无WEB。CONFIG文件.目录:"& server.mappath("."))
response.end()
END IF
end if
end sub
</script>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改WEB.CONFIG文件</title>
<style type="text/css">
body{font-size:12px;}
.div1{width:770px; margin:0 auto;}
ul{list-style:nono; margin:0px; border:#eaeaea dashed 1px; cursor:default;}
li{margin:0px; float:left;height:20px;}
.li1{width:200px; padding-top:2px; padding-left:8px;}
.li2{width:500px;}
.li3{width:740px;}
.li4{width:40px; background-color:#eaeaea;}
.li4{text-align:center; padding-top:2px;}
input{font-size:12px;}
</style>

</head>
<body>
<form action="?action=editok" method="post" name="form1">
<div class="div1">
<%
dim ds1 as new dataset()
ds1.readxml(server.MapPath("web.config"))
%>
<ul>
<li class="li3"><span style="font-size:14px;color:#FF0000;margin-left:10px; padding-right:10px;">修改WEB.CONFIG文件</span>文件共有条数:<%=ds1.tables(1).rows.count%> | 列数: <%=ds1.tables(1).columns.count%></li>
</ul>
<%
dim i as integer
for i=0 to ds1.tables(1).rows.count-1
%>

<ul id="tbList">
<li class="li4"><%=i+1%></li>
<li class="li1"><%=ds1.tables(1).rows(i)(0)%></li>
<li class="li2"><input type="text" name="s<%=i%>" value="<%=ds1.tables(1).rows(i)(1)%>" size="65" /></li>
</ul>
<%
next
ds1.Clear()
ds1.Dispose()
%>
<ul>
<li class="li3" style="text-align:center;"><input type="submit" value="提交修改" name="submit" />
<input type="reset" value="恢复原值" name="reset" /></li>
</ul>
</div>
</form>

</body>
</html>
我没有做到修改SYSTEM。WEB
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@ import namespace="system.data"%>
<%@ import namespace="system.io"%>
<script runat="server">
sub page_load(s as object,e as eventargs)
if request.QueryString("action")="editok" then
dim n as integer
dim ds as new dataset()
ds.readxml(server.MapPath("web.CONFIG"))
for n=0 to ds.tables(1).rows.count-1
ds.tables(1).rows(n)(1) = request.Form("s"& n)
next
ds.AcceptChanges()
ds.WriteXml(Server.MapPath("web.config"))
ds.Clear()
ds.Dispose()
response.Write("<script>alert('修改成功');location.href='?';</sc"&"ript>")
else
if file.exists(server.mappath("Web.config"))=FALSE THEN
response.write("当前目录无WEB。CONFIG文件.目录:"& server.mappath("."))
response.end()
END IF
end if
end sub
</script>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改WEB.CONFIG文件</title>
<style type="text/css">
body{font-size:12px;}
.div1{width:770px; margin:0 auto;}
ul{list-style:nono; margin:0px; border:#eaeaea dashed 1px; cursor:default;}
li{margin:0px; float:left;height:20px;}
.li1{width:200px; padding-top:2px; padding-left:8px;}
.li2{width:500px;}
.li3{width:740px;}
.li4{width:40px; background-color:#eaeaea;}
.li4{text-align:center; padding-top:2px;}
input{font-size:12px;}
</style>
</head>
<body>
<form action="?action=editok" method="post" name="form1">
<div class="div1">
<%
dim ds1 as new dataset()
ds1.readxml(server.MapPath("web.config"))
%>
<ul>
<li class="li3"><span style="font-size:14px;color:#FF0000;margin-left:10px; padding-right:10px;">修改WEB.CONFIG文件</span>文件共有条数:<%=ds1.tables(1).rows.count%> | 列数: <%=ds1.tables(1).columns.count%></li>
</ul>
<%
dim i as integer
for i=0 to ds1.tables(1).rows.count-1
%>
<ul id="tbList">
<li class="li4"><%=i+1%></li>
<li class="li1"><%=ds1.tables(1).rows(i)(0)%></li>
<li class="li2"><input type="text" name="s<%=i%>" value="<%=ds1.tables(1).rows(i)(1)%>" size="65" /></li>
</ul>
<%
next
ds1.Clear()
ds1.Dispose()
%>
<ul>
<li class="li3" style="text-align:center;"><input type="submit" value="提交修改" name="submit" />
<input type="reset" value="恢复原值" name="reset" /></li>
</ul>
</div>
</form>
</body>
</html>



浙公网安备 33010602011771号