我想使用c#.net以Web形式在td中添加html div [英] i want to add html div in td in web form using c#.net

查看:127
本文介绍了我想使用c#.net以Web形式在td中添加html div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我要添加
使用c#.net代码在asp.net设计中的td中使用

例如这是我的桌子

test.html文件
< div>
< table>
< tr>
< td>
一些文字....
</td>
</tr>
</table>
</div>


test.aspx文件

< body>
< table>
< tr>
< td>
标题
</td>
</tr>
< tr>
< td>
在这里我要插入
来自test.html文件.
</td>
</tr>
< table>
</body>

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
<div>
<table>
<tr>
<td>
some text here....
</td>
</tr>
</table>
</div>


test.aspx file

<body>
<table>
<tr>
<td>
Heading
</td>
</tr>
<tr>
<td>
here i want insert
from test.html file.
</td>
</tr>
<table>
</body>

推荐答案

只需执行以下操作-

在设计页面中添加一个文字控件-

Just do as follows -

In design page add one literal control -

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



然后在.cs页面中-



Then in .cs page -

protected void Page_Load(object sender, EventArgs e)
        {
            StreamReader sr;
            string html;
            sr = File.OpenText(Server.MapPath("FileName.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;
        }



它将html文件内容添加到aspx页面.



It will add the html file contents to the aspx page.


这篇关于我想使用c#.net以Web形式在td中添加html div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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