从数据库检索html数据作为文本. [英] retrieve html data from database as text.

查看:101
本文介绍了从数据库检索html数据作为文本.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用ftb编辑器将数据插入数据库.但显示为html格式,例如

i have inserted data into database using ftb editor. but display the as html format such as

<h2 class="title">Md Shahdat Hosain's Bio</h2>
            <div class="entry">
                <p >I was born on July 03, 1986 in Comilla, Bangladesh. My primary and high school life was be passed with our family. I went to primary school by <b>run</b> with my father, beacause he was a teacher of that school and his walk was equal to my run, It was two kilometer away from home. My high school life? it was so memorable, The high school is three kilometer away from my home. I went to here by walk also. The day of coldest/winter session is shorter than night in Bangladesh. So At that days sometime I had to reach to home from school after sunset and had to said Magrib/Evening prayer at street mosque, after having dinner just went to bad and sleep of whole world came to me. I flew to comilla town to spend my college life. No more at here
</p>

            </div>


但需要此代码的输出
这是我的代码=


but need output of this code
here is my code=

protected void Button2_Click(object sender, EventArgs e)
   {
       using (DataClassesDataContext context = new DataClassesDataContext())
       {
           var customers =
             from c in context.tests
             select c;

           Label1.Text = customers;
       }
   }


帮助我

推荐答案

您需要对存储在数据库中的值进行编码,然后才能在屏幕上显示.

试试这个.


You need to encode the value stored in the database before displaying on the screen.

try this.


Label1.Text = Server.HtmlEncode(customers);


这篇关于从数据库检索html数据作为文本.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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