Asp.net 2.0 中获取控件输出的Html代码
2007-01-17 10:33
274 查看
将Asp.net 控件的呈现html获取,在不少场合会用到,比如生成静态页时
以下代码选自 Asp.net 2.0 高级编程
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public static string RenderControlAsString(Control ctl)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StringWrite sw=new StringWrite();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HtmlTextWrite write=new HtmlTextWrite(sw);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ctl.RenderControl(writer);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string str =sw.ToString();
write.Close();
sw.Close();
return str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
以下代码选自 Asp.net 2.0 高级编程
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
public static string RenderControlAsString(Control ctl)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
StringWrite sw=new StringWrite();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HtmlTextWrite write=new HtmlTextWrite(sw);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ctl.RenderControl(writer);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
string str =sw.ToString();
write.Close();
sw.Close();
return str;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- Asp.net 2.0 中获取控件输出的Html代码
- Asp.net 2.0 中获取控件输出的Html代码 (转)
- 技巧和诀窍:使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 技巧和诀窍:使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 技巧和诀窍:使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- 使用ASP.NET 2.0 CSS 控件适配器生成CSS友好的HTML输出
- ASP.NET 2.0中的页面输出缓存3
- [翻译]Scott Mitchell 的ASP.NET 2.0数据教程之十二:在GridView控件中使用TemplateField
- 在ASP.NET 2.0中直接得到本页面生成的HTML代码
- 【转贴】使用ASP.NET 2.0 DetailsView控件处理数据
- ASP.NET中动态获取数据使用Highcharts图表控件【Copy By Internet】
- ASP.NET 2.0 的数据绑定控件概述与区别(GridView、DetailsView、FormView 、Repeater、DataList)
- Scott Mitchell 的ASP.NET 2.0数据教程之三十二:: 数据控件的嵌套
- ASP.NET 2.0中Gridview控件技巧(1)
- 利用ASP.NET 2.0创建自定义Web控件
- 利用ASP.NET 2.0创建自定义Web控件
- ASP.NET 2.0中的页面输出缓存