Click here to Skip to main content
15,885,126 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
HTML
<table id="demo" runat="server" style="width:100%;">
   ..............
   .......................
</table>

and server side
C#
HtmlTable  cont = (HtmlTable)this.FindControl("demo");
string tablevalue = cont.InnerHtml;

but here error is showing me
'HtmlTable' does not support the InnerHtml property.
Posted
Updated 20-Jan-12 5:17am
v2

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.
 
Share this answer
 
Comments
Surendra Tarai 20-Jan-12 22:34pm    
then how will a get it if this situation will come ?
BobJanova 21-Jan-12 7:14am    
I don't understand this question.
html code:

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


csharp code:
C#
string innerhtml = demo.InnerHtml;
 
Share this answer
 
Comments
NandaKumer 20-Jan-12 13:43pm    
good one
Surendra Tarai 20-Jan-12 22:22pm    
I have written first like this, still this error is showing
 
Share this answer
 
v4
Comments
fjdiewornncalwe 20-Jan-12 11:17am    
Just fixed your link.
Use javascript to get innerHTML .
document.getElementById("tblID").innerHTML
 
Share this answer
 
Comments
NandaKumer 20-Jan-12 13:43pm    
good one..!!
Surendra Tarai 20-Jan-12 22:29pm    
ya, i know how to get it in javascript as well as j-query but i want to get it in server side using c# and asp.net
[no name] 21-Jan-12 9:42am    
You take a label control and set innerText of label using javascript.

On server side, fetch value of label, it gives innerHTML of table.

Use this. And Rate accordingly.
If table is defind as RuntAt server then only u can user that id in server side code
demoI.nnerHtml u will ge the value
 
Share this answer
 
Comments
Surendra Tarai 20-Jan-12 7:21am    
then also same error is showing
Hi, try putting the table in the panel, then call panel1.rendercontrols

http://stevesmithblog.com/blog/render-control-as-string/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900