Filling with HTML

Posted on 2005-05-01
Last Modified: 2010-04-07
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"
Question by:chrisryhal
    LVL 13

    Accepted Solution

    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?
    LVL 12

    Assisted Solution

    You can use a <span> tag
    <span id="msg" runat=server>

    in code:
    dim str as string="<b>Hello World</b>"
    msg.innerhtml = str
    LVL 26

    Assisted Solution

    response.write (UrHTML) will write the HTMcode as it is

    So a
    response.write ("<b>Hello World</b>")
    will show the text in bold ....
    LVL 2

    Author Comment

    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

    LVL 2

    Author Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Suggested Solutions

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now