1.我是新手,关于动态页面生成静态页面原理不理解,比如一个.aspx文件,要对数据进行添加,删除等操作!如果生成静态页面后,那个这个被生成的静态页面是怎么样对数据进行操作,怎么对数据库中的表进行操作的呢?2.所以我个人理解是这样,当一个.aspx文件对数据进行操作完后,有一个显示操作成功后的结果页面,而这个页面才是真正的被生成静态页面。。
3.下面有一个例子,是在有一个数据源控件的情况下显示数据,麻烦哪个帮忙看看怎么样生成静态页面,这样有助于我理解
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
<Columns>
<%#Eval("Id")>
<%#Eval("Name")>
<%#Eval("Message")> </Columns>
</asp:GridView>
后台:
protected void Page_Load(object sender, EventArgs e)
{
// 数据绑定
}
3.下面有一个例子,是在有一个数据源控件的情况下显示数据,麻烦哪个帮忙看看怎么样生成静态页面,这样有助于我理解
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
<Columns>
<%#Eval("Id")>
<%#Eval("Name")>
<%#Eval("Message")> </Columns>
</asp:GridView>
后台:
protected void Page_Load(object sender, EventArgs e)
{
// 数据绑定
}
2 所以你理解错误了
3 不是高负载,不用生成静态页面。楼主不要没事找事
{
bool Flage = false;
StreamReader ReaderFile = null;
StreamWriter WrirteFile = null;
//修改mode.htm到inc目录下
strModeFilePath = "../inc/" + strModeFilePath;
string FilePath = HttpContext.Current.Server.MapPath(strModeFilePath);
Encoding Code = Encoding.GetEncoding("gb2312");
string strFile = string.Empty;
try
{
ReaderFile = new StreamReader(FilePath, Code);
strFile = ReaderFile.ReadToEnd(); }
catch (Exception ex)
{
throw ex;
}
finally
{
ReaderFile.Close();
}
try
{
int intLengTh = strNewsHtml.Length;
for (int i = 0; i < intLengTh; i++)
{
strFile = strFile.Replace(strOldHtml[i], strNewsHtml[i]);
}
WrirteFile = new StreamWriter(HttpContext.Current.Server.MapPath(strPageFilePath), false, Code);
WrirteFile.Write(strFile);
Flage = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{ WrirteFile.Flush();
WrirteFile.Close();
}
return Flage;
}
public static bool UpdateHtmlPage(string[] strNewsHtml, string[] strStartHtml, string[] strEndHtml, string strHtml)
{
bool Flage = false;
StreamReader ReaderFile = null;
StreamWriter WrirteFile = null;
string FilePath = HttpContext.Current.Server.MapPath(strHtml);
Encoding Code = Encoding.GetEncoding("gb2312");
string strFile = string.Empty;
try
{
ReaderFile = new StreamReader(FilePath, Code);
strFile = ReaderFile.ReadToEnd(); }
catch (Exception ex)
{
throw ex;
}
finally
{
ReaderFile.Close();
}
try
{
int intLengTh = strNewsHtml.Length;
for (int i = 0; i < intLengTh; i++)
{
int intStart = strFile.IndexOf(strStartHtml[i]) + strStartHtml[i].Length;
int intEnd = strFile.IndexOf(strEndHtml[i]);
string strOldHtml = strFile.Substring(intStart, intEnd - intStart);
strFile = strFile.Replace(strOldHtml, strNewsHtml[i]);
}
WrirteFile = new StreamWriter(FilePath, false, Code);
WrirteFile.Write(strFile);
Flage = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{ WrirteFile.Flush();
WrirteFile.Close();
}
return Flage;
}
如何生成静态页面的五种方案