Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I want to add
within td in asp.net design using c#.net code

for example this is my table

test.html file
XML
<div>
<table>
<tr>
<td>some text here....
</td>
</tr>
</table>
</div>


test.aspx file
XML
<body>
<table>
<tr>
<td>Heading
</td>
</tr>
<tr>
<td>  here i want insert <div> from test.html file.
</div></td>
</tr>
</table>
</body></div>
Posted
Updated 18-Jan-12 13:35pm
v3

Hello,

How about a small function call , use jQuery .load() function (ofcurse this is in addition to adding the jQuery Js reference at the start :) ).

say you have the a Div having the "DivToLoadIn" id and you want to fill it with the contents of an HTMl File you have on the server say "HTMLPage.htm" the following will do it all :
C#
$("#DivToLoadIn").load("HTMLPage.htm");

moreover if u just want the content of one specific element in that HTML page say the DIV "DivToGGetFrom" then

C#
$("#DivToLoadIn").load("HTMLPage.htm #DivToGGetFrom");

check the jQuery site its so powerful.

hope this was of a value! , Good luck :)
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 19-Jan-12 6:13am    
Added pre tag
Tech Code Freak 19-Jan-12 8:26am    
5up!
Just do as follows -

In design page add one literal control -

XML
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Literal ID="htmlbody" runat="server"></asp:Literal>
    </div>
    </form>
</body>


Then in .cs page -

protected void Page_Load(object sender, EventArgs e)
        {
            StreamReader sr;
            string html;
            sr = File.OpenText(Server.MapPath("New.html"));
            html = sr.ReadToEnd();
            sr.Close();

            Regex start = new Regex(@"[\s\S]*<body[^<]*>",RegexOptions.IgnoreCase);
            html = start.Replace(html, "");
            Regex end = new Regex(@"</body[\s\S]*",RegexOptions.IgnoreCase);
            html = end.Replace(html, "");
            htmlbody.Text = html;
        }


It will add the html file contents to the aspx page.
 
Share this answer
 
Hi, use iframe between body tag and set src of that html page.
 
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