• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Filling with HTML

I have Pure HTML stored in tables in SQL.  I already know how to perform a SQL Connection and such, but what control on an ASP.NET page using VB.NET will convert the HTML, into something a user can read?  For example, can I use a textbox, or a picture box, or what?

So.....If the html were something simple like:  <b>Hello World</b>  then how to display that on a ASP.NET page, and make it display to the user a BOLD "Hello World"
3 Solutions
Hi chrisryhal,
I assume you ran into the problem of ASP.NET rendering the controls for you? :) That's got to be the one "feature" that cost me the most sleep (even though it's neat enough). Since you can't use a Label (which is rendered), you'll want to use a Literal:

<asp:literal id="ltlText" runat="server" />

which you can set easily enough:

ltlText.Text = [data from database]

Was that about what you were looking for?
You can use a <span> tag
<span id="msg" runat=server>

in code:
dim str as string="<b>Hello World</b>"
msg.innerhtml = str
response.write (UrHTML) will write the HTMcode as it is

So a
response.write ("<b>Hello World</b>")
will show the text in bold ....
chrisryhalAuthor Commented:
Ok, I am going to try all the options, but maybe if you could help get me past this really quick.  I am not understanding why I get an error on:

        myCommand.SelectCommand.Parameters.Add(New SqlParameter("@Id", SqlDbType.NVarChar, 11))
        myCommand.SelectCommand.Parameters("@Id").Value = Request.QueryString("id")

Saying, that "SelectCommand" is not a member of Imports System.Data.SqlClient.  I have the namespace declared

Here is the code:

        Dim DS As DataSet
        Dim MyConnection As SqlConnection
        MyConnection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("MAXASPCONNECTION"))

        'Dim MyCommand As SqlDataAdapter

        Dim SelectCmd As String = "SELECT HTML " _
                         & "FROM Benchmarking " _
                         & "WHERE ID = @ID"

             Dim myConn As New SqlConnection(SelectCmd)
        Dim myCommand As New SqlCommand(SelectCmd, myConn)

        myCommand.SelectCommand.Parameters.Add(New SqlParameter("@Id", SqlDbType.NVarChar, 11))
        myCommand.SelectCommand.Parameters("@Id").Value = Request.QueryString("id")


        Dim dr As SqlDataReader
        dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

        If dr.Read = True Then
            Literal1.Text = dr("HTML") & ""
        End If

chrisryhalAuthor Commented:
To explain further, the URL is:  "Benchmarking_details.aspx?id=1"


Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now