如何获得在C#中的表的innerHTML [英] How to get innerHTML of a Table in C#

查看:1286
本文介绍了如何获得在C#中的表的innerHTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 HtmlTable baseCalendar = new HtmlTable();
 HtmlTableRow calendarRow=new HtmlTableRow();
 HtmlTableCell calendarCell = new HtmlTableCell();

 for(int i=0;i<6;i++){
       calendarCell = new HtmlTableCell();

       calendarCell.Controls.Add(new LiteralControl(i.ToString()));
       calendarCell.Style.Add("color", "red");
       calendarRow.Cells.Add(calendarCell);

 }



 string resutlt=baseCalendar.innerHtml.Tostring();

这行说错误:HTMLTABLE不支持InnerHtml属性?????

this line say error:HtmlTable' does not support the InnerHtml property?????

推荐答案

我希望你想要的HTML code,对于它不能用innerHTML的那些是有效的DIV的情况下,可以实现您所创建的表,在这里你应该相当使用 RenderControl 东西就这些行

I hope you want the HTML code for the table you created which cannot be achieved by innerHTML those are valid in case of div, here you should rather use RenderControl something on these lines

StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
baseCalendar.RenderControl(htw)

这篇关于如何获得在C#中的表的innerHTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆