All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET,AJAX视频下载_[Asp.Net教程]
delphi映像内存接收端
自己写的一个图形验证码页面(Asp.Net2.0通过)_[Asp.Net教程]
vs2008中文版提供下载(包含中文msdn)_[Asp.Net教程]
PHP入门:动态网页制作技术PHP的常量类型_[PHP教程]
Sqlserver常用函数例子说明_[SQL Server教程]
使用Forms,Authentication实现用户注册、登录,(二)用户注册与登录_[Asp.Net教程]
轻松掌握Ajax.net系列教程四:用Ajax.net实现客户端回调(Callback)_[Asp.Net教程]
ASP.NET Remoting体系结构(九)
一些关于SQL2005+ASP.NET2.0的问题_[Asp.Net教程]
Reading number is top 10 pictures
Send some Valentine's day cartoon
The money of more than 100 countries and regions6
世界各国15岁的MM有什么不同
奇趣的世界记录2
一万二一支的万珂,用得真心肉疼。
The money of more than 100 countries and regions8
俄罗斯台球天后惊艳魅惑1
yy365网站上的美女3
The real super beauty3
The money of more than 100 countries and regions14
Download software ranking
Professional killers2 for Android
双旗镇刀客B
Boxer Classic video1
Tram sex maniac 2 (H) rar bag9
Tram sex maniac 2 (H) rar bag2
Unix video tutorial12
WebService在.NET中的实战应用教学视频 → 第2集
The Bermuda triangle1
传奇私服架设教程
Unix video tutorial18
delv published in(发表于) 2014/1/24 9:03:09 Edit(编辑)
ASP.NET,生成HTML静态页面实例_[Asp.Net教程]

ASP.NET,生成HTML静态页面实例_[Asp.Net教程]

ASP.NET 生成HTML静态页面实例_[Asp.Net教程]























1 配置WEB.CONFIG
复制XML代码保存代码












2.创建模板页
阅读代码编辑代码运行效果复制HTML代码保存代码


my_title





生成时间:my_time


作者: my_name




替换的正文:my_body


[ DllImport( "kernel32", EntryPoint="GetVersionEx" )]
DllImportAttribute特性的公共字段如下: 1、CallingConvention 指示向非托管实现传递方法参数时所用的
CallingConvention 值。 CallingConvention.Cdecl : 调用方清理堆栈。它使您能够调用具有 varargs 的函数。
CallingConvention.StdCall : 被调用方清理堆栈。它是从托管代码调用非托管函数的默认约定。 2、CharSet
控制调用函数的名称版本及指示如何向方法封送 String 参数。 此字段被设置为 CharSet 值之一。如果 CharSet 字段设置为
Unicode,则所有字符串参数在传递到非托管实现之前都转换成 Unicode 字符。






my_title





生成时间:my_time


作者: my_name




替换的正文:my_body


[ DllImport( "kernel32", EntryPoint="GetVersionEx" )]
DllImportAttribute特性的公共字段如下: 1、CallingConvention 指示向非托管实现传递方法参数时所用的
CallingConvention 值。 CallingConvention.Cdecl : 调用方清理堆栈。它使您能够调用具有 varargs 的函数。
CallingConvention.StdCall : 被调用方清理堆栈。它是从托管代码调用非托管函数的默认约定。 2、CharSet
控制调用函数的名称版本及指示如何向方法封送 String 参数。 此字段被设置为 CharSet 值之一。如果 CharSet 字段设置为
Unicode,则所有字符串参数在传递到非托管实现之前都转换成 Unicode 字符。






3. 写静态页类
using System;
using System.IO;




namespace Junval.createHtm
{
///


/// ExcetueHtm 的摘要说明。
///

public class ExcetueHtm
{
private string sId; //需要生成静态页的数据ID
private string sTemp; //需要生成静态页的模板名称
public ExcetueHtm()
{
//
// TOD 在此处添加构造函数逻辑
//
}




///


/// 设置ID属性
///

public string ID
{
get { return sId; }
set { sId = value; }
}




public string Temp
{
get { return sTemp; }
set { sTemp = value; }
}




///


/// 生成静态页面
///

///
public bool CreateHtml()
{
//存放HTML路径
string ls_path = System.Configuration.ConfigurationSettings.AppSettings["htmlPath"].ToString();
//选择模板
string ls_temp = ls_path + sTemp;




System.IO.StreamReader Sr = null;
System.IO.StreamWriter Sw = null;
string str = "";
//读模板
try
{
Sr = new StreamReader(ls_temp, System.Text.Encoding.GetEncoding("GB2312"));
str = Sr.ReadToEnd();
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message.ToString());
System.Web.HttpContext.Current.Response.End();
}
finally
{
Sr.Close();
}




string sFilename = sId.ToString() + ".htm";
//替换模板内容
str = ReplaceStr(str);
//写vhtml
try
{
Sw = new StreamWriter(ls_path + sFilename, false, System.Text.Encoding.GetEncoding("gb2312"));
Sw.Write(str);
Sw.Flush();
}
catch (Exception ex)
{
System.Web.HttpContext.Current.Response.Write(ex.Message.ToString());
System.Web.HttpContext.Current.Response.End();
}
finally
{
Sw.Close();
}
return true;
}




private string ReplaceStr(string ls_str)
{
//根据模板 选择不通的替换函数
return TempNo_1(ls_str).ToString();
}




//NO1模板替换方案
private string TempNo_1(string ls_str)
{
string ls_Tilte = "标题:一号模板替换方案";
string ls_time = DateTime.Now.ToString();
ls_str = ls_str.Replace("my_title", ls_Tilte);
ls_str = ls_str.Replace("my_time", ls_time);
ls_str = ls_str.Replace("my_name", "Junval Shi");
ls_str = ls_str.Replace("my_body", " ......");
return ls_str;
}




///


/// 生成静态页面
///

/// 需要生成静态页的数据ID
/// 需要生成静态页的模板名称
///
public bool CreateHtml(string pid, string ptemp)
{
return true;
}
}
}
<%@ Page language="c#" Codebehind="Main.aspx.cs" AutoEventWireup="false" Inherits="Junval.createHtm.Main" %>



Main








runat="server" Text="CreateHtml">


<%@ Page language="c#" Codebehind="Main.aspx.cs" AutoEventWireup="false" Inherits="Junval.createHtm.Main" %>



Main








runat="server" Text="CreateHtml">





CS:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;




namespace Junval.createHtm
{
///


/// Main 的摘要说明。
///

public class Main : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button CreateHtml;




private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}




#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}




///


/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///

private void InitializeComponent()
{
this.CreateHtml.Click += new System.EventHandler(this.CreateHtml_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion




private void CreateHtml_Click(object sender, System.EventArgs e)
{
string ls_id = TextBox1.Text.Trim();
ExcetueHtm CH = new ExcetueHtm();
CH.ID = ls_id;
CH.Temp = "HTMLPage1.html";
if (CH.CreateHtml())
{
Response.Write("");
}
else
{
Response.Write("ErrEs");
}
}
}
}

来源:CSDN













































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.