首页 > 编程 > .NET > 正文

Asp.Net生成静态页面的实现方法

2024-07-10 12:44:33
字体:
来源:转载
供稿:网友

代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Mysqlserver;//数据库操作类
using System.IO;
using System.Text;
namespace NewsAdd
{
    public partial class Admin_AdminPanel_NewsAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string strTitle=Request.Form["Title"].ToString();
            string strContent=Request.Form["Content"].ToString();
            SqlServerDataBase db = new SqlServerDataBase();
            bool success = db.Insert("insert into inNews(Title,Content)values('" + strTitle + "','" + strContent + "')", null);
            //if (success)
               // Message.Text = "添加成功!";
            /**////////////////////////////创建当前日期的文件夹开始
            string dir = Server.MapPath("../../"+"NewsFiles/"+DateTime.Now.ToString("yyMMdd"));
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            /**////////////////////////////创建当前日期的文件夹结束

            string[] newContent = new string[5];//定义和html标记数目一致的数组
            StringBuilder strhtml = new StringBuilder();
            try
            {
                //创建StreamReader对象
                using (StreamReader sr = new StreamReader(Server.MapPath("../../" + "NewsFiles/") + "/template.html"))

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表