asp.net 动态加载html文件 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!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><title>${CBM:PUBLIC.TFormTitle}</title><link href="/css/default/Templatecss.css" rel="stylesheet" type="text/css" /><style type="text/css"><!--.STYLE1 { font-size: 14pt; font-weight: bold;}.STYLE2 { font-size: 24pt; font-weight: bold;}.STYLE4 {font-size: 12px; font-weight: bold; }--></style></head><body><form action="" name="Frm_TFormView" method="post"> <table width="640px" height="95%" border="0" align="center" cellpadding="1" cellspacing="0" bordercolor="#000000"> <tr> <td height="400" bgcolor="#C2D4DA"><table width="98%" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF" class="tform"> <tr> <th width="140" align="left" class="STYLE1">申报工程名称:</th> <td colspan="2" align="left" class="AlignLeftInput">${CBM:View.Row_4660}</td> </tr> <tr> <th align="left" class="STYLE1">申 报 单 位:</th> <td width="431" align="left" class="AlignLeftInput">${CBM:View.Row_4661}</td> <td width="40" align="left" class="AlignLeftInput"><span class="STYLE4">(公章)</span></td> </tr> <tr> <th align="left" class="STYLE1">申 报 日 期:</th> <td colspan="2" class="textcenter">${CBM:View.Row_4662}</td> </tr> </table></td> </tr> </table></body></html>这是html文件 读取该文件 然后按照你的需要替换${CBM:View.Row_4662}这类 回复 peterb 现在关键问题是 替换后的字符串怎么呈现给用看到 字符串中有css等 引用using System.IO; string str=""; Response.Charset = "gb2312"; Page.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); HtmlTextWriter wt = new HtmlTextWriter(tw); //读取生成页面的代码 Server.Execute("../template.aspx", tw); //把源码赋给字符串,接下来就是你要用Replace来处理了 str= tw.ToString(); tw.Close(); 你是指生成静态页,还是把html代码动态的写入asp.net中呢? HttpWebRequest我试了 是要生成一个对应文件 我现在不想生成这个文件 把html代码动态的写入asp.net中 回复 aiyumen 你的方法可以把html文件读出来了 可是怎么显示给用户看到了 不生成新的页面 呵呵,这个嘛,用httpHandels,你看看这个你就明白了http://webuc.net/dotey/archive/2004/06/08/966.aspx 你动态显示在页面中,取得请求文件流后在Response.write不就可以了吗? this.GridView1.DataSource = CreateTable(); this.GridView1.DataBind(); //this.Request.Url.ToString().Replace("Default.aspx","") + "Default2.aspx" System.Net.WebRequest request = System.Net.WebRequest.Create("http://www.csdn.net/"); System.Net.WebResponse response = request.GetResponse(); Response.Write(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd()); 关于模板的设计问题 订单产品多种价格操作问题 如何实现像msdn中的布局? 统计代码是如何判断网站来路的 Timeout expired如何解决 请问关于数组问题?? dropdownlist问题 如何用VS2008可以画用例图和数据库关系图 这个错误怎么改?大家帮帮忙。 简单的问题,查询时提示"正在查询...",结束后提示"查询完毕" 一个简单问题 windows验证
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${CBM:PUBLIC.TFormTitle}</title>
<link href="/css/default/Templatecss.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 { font-size: 14pt;
font-weight: bold;
}
.STYLE2 { font-size: 24pt;
font-weight: bold;
}
.STYLE4 {font-size: 12px; font-weight: bold; }
-->
</style>
</head>
<body>
<form action="" name="Frm_TFormView" method="post">
<table width="640px" height="95%" border="0" align="center" cellpadding="1" cellspacing="0" bordercolor="#000000">
<tr>
<td height="400" bgcolor="#C2D4DA"><table width="98%" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF" class="tform">
<tr>
<th width="140" align="left" class="STYLE1">申报工程名称:</th>
<td colspan="2" align="left" class="AlignLeftInput">${CBM:View.Row_4660}</td>
</tr>
<tr>
<th align="left" class="STYLE1">申 报 单 位:</th>
<td width="431" align="left" class="AlignLeftInput">${CBM:View.Row_4661}</td>
<td width="40" align="left" class="AlignLeftInput"><span class="STYLE4">(公章)</span></td>
</tr>
<tr>
<th align="left" class="STYLE1">申 报 日 期:</th>
<td colspan="2" class="textcenter">${CBM:View.Row_4662}</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
这是html文件
引用
using System.IO; string str="";
Response.Charset = "gb2312";
Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter wt = new HtmlTextWriter(tw);
//读取生成页面的代码
Server.Execute("../template.aspx", tw);
//把源码赋给字符串,接下来就是你要用Replace来处理了
str= tw.ToString();
tw.Close();
你看看这个你就明白了
http://webuc.net/dotey/archive/2004/06/08/966.aspx
this.GridView1.DataBind();
//this.Request.Url.ToString().Replace("Default.aspx","") + "Default2.aspx"
System.Net.WebRequest request = System.Net.WebRequest.Create("http://www.csdn.net/");
System.Net.WebResponse response = request.GetResponse();
Response.Write(new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd());