-1

I have some text with HTML tags retrieved from an SQL database. How could I display the same text without the HTML tags in the browser using asp.net ?

0

2 Answers 2

0

You can use @Html.Raw(Model.text) to print html

Sign up to request clarification or add additional context in comments.

Comments

0

I got it using form-view to bind the database to get the result.

If you stored some message with HTML tags to view in browser use this:

project.aspx page

'<asp:FormView ID="fvhtml" runat="server" Width="100%">
    <ItemTemplate>
        <asp:Label ID="lblmsg" runat="server" Text="Message" Font-Size="25px"></asp:Label>
        <asp:Label ID="lblhtml" runat="server" Text='<%# Bind("**`column name`**") %>' />
        <br />
    </ItemTemplate>
</asp:FormView>'

project.aspx.cs

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring name"].ToString());

//message binding start from here
try
{
    con.Open();
    SqlDataAdapter sqlda = new SqlDataAdapter("SELECT TOP 1 column name FROM table name", con);
    DataTable dt = new DataTable();
    sqlda.Fill(dt);
    fvhtml.DataSource = dt;
    fvhtml.DataBind();
}
catch (Exception ex)
{
    ex.Message.ToString();
}
finally
{
    con.Close();
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.