获取HTML表的innerHTML [英] Get innerHTML of HTML table

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

问题描述

我的ruat服务器在default.aspx文件中有一个html表.
但是我想获取此表的innerHtml并在服务器端的任何地方使用它
只是我的页面代码是这样的

I have a html table in my default.aspx file with ruat server.
but i want to get the innerHtml of this table and user it any where with server side
Just my page codes like this

<table id="demo" runat="server" style="width:100%;">
   ..............
   .......................
</table>


和服务器端


and server side

HtmlTable  cont = (HtmlTable)this.FindControl("demo");
string tablevalue = cont.InnerHtml;


但是这里的错误向我显示
"HtmlTable"不支持InnerHtml属性.


but here error is showing me
''HtmlTable'' does not support the InnerHtml property.

推荐答案

您从根本上误解了ASP.net的工作方式.在服务器端,对于控件,没有HTML –仅当控件经过呈现过程以创建客户端标记时,HTML才存在.

您需要通过对象公开的方法和属性来更改对象的属性,以使其在渲染时生成所需的标记.
You are fundamentally misunderstanding how ASP.net works. On the server side, for a control, there is no HTML – the HTML only exists once controls go through the rendering process to create client side markup.

You need to change the properties of the object through the methods and properties that it exposes, in order to have it generate the markup you want at render time.


检查这些博客
http://www.mredkj.com/tutorials/tablebasics3.html [ http://msdn. microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.innerhtml%28v=vs.80%29.aspx [
check these blogs
http://www.mredkj.com/tutorials/tablebasics3.html[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmltable.innerhtml%28v=vs.80%29.aspx[^]
--NDK


html代码:

html code:

<table id = "demo" runat ="server">
    </table>



csharp代码:



csharp code:

string innerhtml = demo.InnerHtml;


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

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