asp.net 生成静态页面
后台:
string strDate = DateTime.Now.ToString("yyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss");
string strFileName = strDate + ".html";
string strTitle = this.Txt_C_Name.Text.Trim();
string strContent = this.Content.Value.Trim();
string[] content = strContent.Split(new Char[] { '^' });//对内容进行拆分,并保存到数组【^】
int upbound = content.Length;//数组的上限
//SqlServerDataBase db = new SqlServerDataBase();
//bool success = db.Insert("insert into inNews(Title,Content,FilePath)values('" + strTitle + "','" + strContent + "','" + strFileName + "')", null);
//if (success)
// Message.Text = "添加成功!";
/**/
///////////////////////////创建当前日期的文件夹开始
string dir = Server.MapPath("../Files/" + DateTime.Now.ToString("yyMMdd"));//用来生成文件夹
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
/**/
///////////////////////////创建当前日期的文件夹结束
try
{
for (int i = 0; i < content.Length; i++)
{
//string[] newContent = new string[4];//定义和html标记数目一致的数组
StringBuilder strhtml = new StringBuilder();
//创建StreamReader对象
using (StreamReader sr = new StreamReader(Server.MapPath("Template/") + "\\template.html", Encoding.GetEncoding("gb2312")))
{
String oneline;
//读取指定的HTML文件模板
while ((oneline = sr.ReadLine()) != null)
{
strhtml.Append(oneline);
}
sr.Close();
}
//为标记数组赋值
//SqlServerDataBase db = new SqlServerDataBase();
//DataSet ds = db.Select("select top 1 NewsId from inNews order by NewsId desc"
相关文档:
在Asp.net中,从A页面中弹出B页面,在B页面中选择数据后,关闭并将数据更新到A页面,是一种常用 的方式。只是我对Javascript不熟悉,所以捣鼓了一下午,终于有了一点成绩:
测试项目有两个页面:Default.aspx及Default2.aspx,在Default.aspx页面上有一个TextBox1及一个Button1,Button1用于触发Default2.aspx,TextBox1用 ......
在开发中经常可以碰到类似的问题: 想通过一个树父节点的TreeNodeCheckChanged 事件( 前提是设置TreeView 的CheckBox 可见), 来选择或反选择全部的子节点, 来实现自己的要实现的操作功能. 于是我们很正常的思维促使我们去寻找TreeView 的的类似于 ” CheckChanged ” 的事件, 很容易我们找到了这个事件 ” ......
这是一篇转载的博文,看了这篇文章,大受启发。因此,稍作修改,转载到我的空间与大家分享,供有需要的同学学习,并呼吁大家一起来学ASP.NET技术!
第一步 掌握一门.NET面向对象语言,C#或VB.NET ,在没有面向对象(OO)基础的情况下直接学ASP.NET是很痛苦的(我深有体会)。ASP.NET是一个全面向对象的技术, ......
1、给web.config添加<authentication>元素
2、给web.config文件添加<forms>元素
<forms name=".aspxauth" loginUrl="Login.aspx" protection="All" timeout="30" path="/" requireSSL="false" slidingExpiration="true" cookieless="UseDeviceProfile"></forms>
3、FormsAuthentication.Redire ......