您的位置:首页 > Web前端 > HTML

ASP.NET WebForm 动态改变输入到客户端的html 代码

2010-11-08 10:12 351 查看
代码如下:

protected override void Render(HtmlTextWriter writer)
{
StringWriter stringWriter = new StringWriter();
HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter);
try
{
base.Render(textWriter);
string repsonseHtml = stringWriter.ToString();
int tempIndex = repsonseHtml.IndexOf("</html>", StringComparison.OrdinalIgnoreCase);
if (tempIndex != -1)
{
//这里可以改变内容
repsonseHtml = repsonseHtml.Insert(tempIndex, "<script type=\"text/javascript\"></script>");
}
writer.Write(repsonseHtml);
}
catch (Exception)
{
}
finally
{
textWriter.Dispose();
stringWriter.Dispose();
stringWriter.Close();
textWriter.Close();
}
}


谢谢阅读。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: