Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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;
but here error is showing me
'HtmlTable' does not support the InnerHtml property.
Posted 20-Jan-12 1:43am
Edited 20-Jan-12 6:17am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

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.
  Permalink  
Comments
Surendra Tarai at 20-Jan-12 22:34pm
   
then how will a get it if this situation will come ?
BobJanova at 21-Jan-12 7:14am
   
I don't understand this question.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

html code:
 
<table id = "demo" runat ="server">
    </table>
 
csharp code:
string innerhtml = demo.InnerHtml;
  Permalink  
Comments
NandaKumer at 20-Jan-12 13:43pm
   
good one
Surendra Tarai at 20-Jan-12 22:22pm
   
I have written first like this, still this error is showing
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
v4
Comments
Marcus Kramer at 20-Jan-12 11:17am
   
Just fixed your link.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Use javascript to get innerHTML .
document.getElementById("tblID").innerHTML
  Permalink  
Comments
NandaKumer at 20-Jan-12 13:43pm
   
good one
Surendra Tarai at 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
Sarvesh Kumar Gupta at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Surendra Tarai at 20-Jan-12 7:21am
   
then also same error is showing
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 9

Hi, try putting the table in the panel, then call panel1.rendercontrols
 
http://stevesmithblog.com/blog/render-control-as-string/[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 21 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100