日期:2014-05-18 浏览次数:20436 次
怎样把这个页面保存为静态页面?静态页面包含从数据库里面读取出来的数据。 <body> <form id="form1" runat="server"> <div> <ul> <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <li><a onclick="headTextBG(); " href="<%#Eval("url")%>" target="left" title=""><span><%#Eval("span")%></span></a></li> </ItemTemplate> </asp:Repeater> </ul> </div> </form> </body>
<%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { StringWriter wr = new StringWriter(); Server.Execute(this.TextBox1.Text, wr); //你可以使用第三个参数传递页面的更多初始数据 this.Label1.Text = Server.HtmlEncode(wr.ToString()); File.WriteAllText(Server.MapPath(this.TextBox2.Text), wr.ToString()); } </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 runat="server"> <title>演示取得网站中其它网页的源代码只需要两行代码就够了</title> </head> <body> <form id="form1" runat="server" defaultbutton="Button1"> <div> 请输入本网站的页面名称:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> 请输入目标文件名称<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><hr /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form> </body> </html>