惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - bestcomy

在OPENSUE 11.3 上安装 sysstat Upload bug in MOSS 2007 / Windows Server 2008 - bestcomy Excel列名转换 Clienside ProgressIndicator - bestcomy - 博客园 ASP.NET MVC 源代码发布! 微软项目组招聘.NET开发人员(北京) 欢迎访问我的新BLOG空间 SharePoint 胡言乱语 你觉得vs.net那些地方让你使用起来很不爽? Include javascript and css dynamically - bestcomy How to set value for webpart’s properties when I create a new sharepoint template Get the true value of a calculate field in SharePoint 调用自定义event时需要注意的一个问题 self==top 如何设置AD用户的"用户下次登陆时须更改密码"属性 (LDAP Provider) 微软 and 香烟 Cool!!! Virtual Earth Technology Preview sth about our coding life 还没有Windows Live Messenger的朋友看过来
Two ways to get HtmlTextWriter for HTML rendering
bestcomy · 2006-11-02 · via 博客园 - bestcomy

I need to render some html in my asp.net applications sometime, I chose HtmlTextWriter to build the html source because I can use those handy methods of this object such as RenderBeginTag, AddAttribute, and so on. I know two ways to do this.

 1 StringBuilder sb = new StringBuilder();
 2             using(StringWriter sw = new StringWriter(sb))
 3             {
 4                 using(HtmlTextWriter output = new HtmlTextWriter(sw))
 5                 {
 6                     output.RenderBeginTag(HtmlTextWriterTag.Table);
 7                     for(int y=0; y<1000; y++)
 8                     {
 9                         output.RenderBeginTag(HtmlTextWriterTag.Tr);
10                         for(int x=0; x<100; x++)
11                         {
12                             output.RenderBeginTag(HtmlTextWriterTag.Td);
13                             output.Write("&nbsp;");
14                             output.RenderEndTag();
15                         }
16                         output.RenderEndTag();
17                         output.Flush();
18                     }
19                     output.RenderEndTag();
20                     Response.Write(output.ToString());
21                 }
22             }

 1 using(MemoryStream stream = new MemoryStream())
 2             {
 3                 using(TextWriter tw = new StreamWriter(stream,System.Text.Encoding.UTF8) as TextWriter)
 4                 {
 5                     using(HtmlTextWriter output = new HtmlTextWriter(tw))
 6                     {
 7                         output.RenderBeginTag(HtmlTextWriterTag.Table);
 8                         for(int y=0; y<1000; y++)
 9                         {
10                             output.RenderBeginTag(HtmlTextWriterTag.Tr);
11                             for(int x=0; x<100; x++)
12                             {
13                                 output.RenderBeginTag(HtmlTextWriterTag.Td);
14                                 output.Write("&nbsp;");
15                                 output.RenderEndTag();
16                             }
17                             output.RenderEndTag();
18                         }
19                         output.RenderEndTag();
20                         output.Flush();
21                         Response.Write(output.ToString());
22                     }
23                 }
24             }