简体   繁体   中英

How to Display Html content from sql database in asp.net webform

I want to display a blog page dynamically from my database,the row which I am retrieving contains html tags so it's displaying the raw html data along with tags,but i want to display it as a page.At present it is displaying like this.

<p>In this article, we'll run down 10 tips you must note before you board a plane. Remember, the primary goal of each of the items on this list is to benefit the traveler, but these tips will also make the whole in-flight experience a lot more comfortable and relaxed.</p> <h4>Take an Water bottle</h4> <p>Spending countless hours on the plane dehydrates your body and skin. My tip is to take a stainless steel water bottle with you that you're able to fill up either just before boarding or on the plane by asking the flight attendant. Most airports have water fountains near the boarding gates. Just make sure that your bottle is empty when you go through the screening points.</p> <img

I want it do be displayed like a page with images being generated on its own. I have tried using Literal Control but it's not working,I have google about this but didn't get a reasonable solution.

There are alot of ways to display the same in asp.net MVC but could'nt find anything for weforms

I would be much obliged if any one could please help me out with this.

Have a markup like this:

<html>
    <body bgcolor="yellow">
        <%MyClass.MyFunction()%>
    </body>
</html>

Naturally, MyClass.MyFunction should return the html loaded from the database.

Take one div in web page

  <div id="webcontent" runat="server"></div>

in Conding Side,assign your string or data fetched from DB to div.

 string str =
    "Please enter your name:<br/>" +
    "<input type='text' name='userName'/>";

 webcontent.InnerHtml = str;

If you want to use javascript and deal with your div, dont forget to set its ClientIdMode to Static:

  <div id="webcontent" runat="server" ClientIdMode="Static"></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM