Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have inserted data into database using ftb editor. but display the as html format such as
XML
<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=
C#
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;
       }
   }

help me
Posted
Comments
Matthew Dennis 8-Jun-10 11:46am    
Is this a Windows Forms Application or a WebForms Application? If Windows Forms, you will need to host the browser to display the HTML as you want.

1 solution

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

try this.


Label1.Text = Server.HtmlEncode(customers);
 
Share this answer
 
Comments
mobasshir 8-Jun-10 14:22pm    
show two error
Error 1 The best overloaded method match for 'System.Web.HttpServerUtility.HtmlEncode(string)' has some invalid arguments
Error 2 Argument '1': cannot convert from 'System.Linq.IQueryable<test>' to 'string'
PSK_ 8-Jun-10 22:12pm    
Server.HtmlEncode have two overload method
1- Server.HtmlEncode(string s)
and 2- Server.HtmlEncode(string s, TextWriter tw)
If "customers" is string (as you are setting it to a text of label) in that case you should not get any error.

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