本文整理汇总了C#中System.Web.UI.HtmlTextWriter.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.Dispose方法的具体用法?C# HtmlTextWriter.Dispose怎么用?C# HtmlTextWriter.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compression
public void Compression(System.Web.UI.HtmlTextWriter writer)
{
StringWriter sr = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sr);
base.Render(tw);
tw.Flush();
tw.Dispose();
StringBuilder sb = new StringBuilder(sr.ToString());
string outhtml = Regex.Replace(sb.ToString(), "\\r+\\n+\\s+", string.Empty);
writer.Write(outhtml);
sr.Dispose();
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder renderedOutput = null;
StringWriter strWriter = null;
HtmlTextWriter tWriter = null;
try
{
renderedOutput = new StringBuilder();
strWriter = new StringWriter( renderedOutput );
tWriter = new HtmlTextWriter( strWriter );
view.RenderControl( tWriter );
tWriter.Flush();
strWriter.Flush();
Response.Write( renderedOutput.ToString() );
Response.Flush();
}
catch( Exception ex )
{
SendJson( new Framework.API.ReturnObject {
Error = true,
Message = "There was an error loading the requested page.",
Result = new {
Message = ex.Message,
Type = ex.GetType().FullName,
StackTrace = ex.StackTrace
}
} );
}
finally
{
if( tWriter != null )
{
tWriter.Close();
tWriter.Dispose();
tWriter = null;
}
if( strWriter != null )
{
strWriter.Close();
strWriter.Dispose();
strWriter = null;
}
}
Response.End();
}
示例3: getHTML
public static String getHTML(WebControl aControl)
{
StringWriter sr = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(sr);
aControl.RenderControl(writer);
writer.Dispose();
return sr.ToString();
}
示例4: ExportToExcel
/// <summary>
/// 导出GridView中的数据到Excel
/// </summary>
/// <param name="gvw"></param>
/// <param name="title"></param>
/// <param name="TableName"></param>
private static void ExportToExcel(GridView gvw, string title, string TableName) {
//int coun = ExistsRegedit();
//string fileName = string.Format("DataInfo{0:yyyy-MM-dd_HH_mm}.xls", DateTime.Now);
//if (coun >0)
//{
// fileName = string.Format("DataInfo{0:yyyy-MM-dd_HH_mm}.xls", DateTime.Now);
// //HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF7;
//}
//else
//{
// HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
// //Page.RegisterStartupScript("mess", "<script>alert('该机器没有安装任何office软件');</script>");
// //return;
//}
for (var i = 0; i < gvw.Rows.Count; i++) {
for (var j = 0; j < gvw.HeaderRow.Cells.Count; j++) {
//这里给指定的列编辑格式,将数字输出为文本,防止数字溢出
gvw.Rows[i].Cells[j].Attributes.Add("style", "vnd.ms-excel.numberformat:@");
//nowrap="nowrap" 不换行
gvw.Rows[i].Cells[j].Attributes.Add("nowrap", "nowrap");
}
}
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
//fileName = string.Format("DataInfo{0:yyyy-MM-dd_HH_mm}.xls", DateTime.Now);
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + HttpUtility.UrlEncode(TableName) + HttpUtility.UrlEncode(title) + ".xls");
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
var tw = new StringWriter();
var hw = new HtmlTextWriter(tw);
gvw.RenderControl(hw);
if (!string.IsNullOrEmpty(title)) {
HttpContext.Current.Response.Write("<b><center><font size=3 face=Verdana color=#0000FF>" + title +
"</font></center></b>");
}
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.Flush();
//HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
gvw.Dispose();
tw.Dispose();
hw.Dispose();
}
示例5: Render
// -----------------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter writer)
{
System.IO.MemoryStream mem = new System.IO.MemoryStream();
System.IO.StreamWriter twr = new System.IO.StreamWriter(mem);
System.Web.UI.HtmlTextWriter myWriter = new HtmlTextWriter(twr);
base.Render(myWriter);
myWriter.Flush();
myWriter.Dispose();
// Write our final output string
writer.Write(AJAXhtmloutput);
}
示例6: GetHTMLGridView
/// <summary>
/// Executa el Render del GridView para generar el Codigo HTML
/// </summary>
/// <param name="grid">Grid</param>
/// <returns></returns>
/// <remarks></remarks>
public static string GetHTMLGridView(GridView grid)
{
StringBuilder sb = new StringBuilder();
StringWriter textwriter = new StringWriter(sb);
HtmlTextWriter htmlwriter = new HtmlTextWriter(textwriter);
grid.RenderControl(htmlwriter);
htmlwriter.Flush();
textwriter.Flush();
htmlwriter.Dispose();
textwriter.Dispose();
return sb.ToString();
}