如何在C#中获取Table的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属性???
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();
this line say error:HtmlTable' does not support the InnerHtml property?????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我希望您想要您创建的表的 HTML 代码,这些代码无法通过 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来自: http ://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.innerhtml%28VS.80%29.aspx
不要读取或分配该属性的价值。否则,将引发 System.NotSupportedException 异常。该属性继承自 HtmlContainerControl 类,不适用于 HtmlTable 类。
From: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.innerhtml%28VS.80%29.aspx
Do not read from or assign a value to this property. Otherwise, a System.NotSupportedException exception is thrown. This property is inherited from the HtmlContainerControl class and is not applicable to the HtmlTable class.
这里你必须使用手动编写一个Table而不是使用HtmlTable
并且在ASPX页面中
Here you have to use manually write a Table instead of using HtmlTable
And in ASPX page
HtmlTable 确实具有 InnerHtml 属性: http:/ /msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.aspx
您缺少一个大写字母:
但是,即使它可以编译,您也必须注意:
A HtmlTable does have the InnerHtml property: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.aspx
You are missing a caps:
However, even though it will compile, you must note that: