HTML file from database to user interface

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

HTML file from database to user interface
I have a html document in a sql server table with tags and elements. I need
to read it from table field and show it in a web page. Is there any
component that I can use to show this html file in the browsed with
interpreting the html tags.
 
Couldn't you just select the rows from the data and write out each raw line
with response.write(<data>)?
 
This page has other components and I need to show this html in the middle
section, I probably need a component that does that.
 
You could put this in a literal control making this html fragment appears at
the exact location you want...
 
An example of which part? You just select the data from the database, loop
through the result set, and for each loop you simply put
"response.write(<yourdata>)"...
 
Here is some sample/psuedo code. This should give you a good idea of
how to implement this.

<%@ Control ClassName="DataBaseHtmlLiteral" %>

<script runat="server">
Public DataBaseID as integer

Sub OnPreRender
' create sql connection and command
SqlCmd = "Select TOP 1
.
HTML:
 from [Table] WHERE [Table].
[IDField] = @ID"
SqlCmd.Parameters.add("@ID",DatabaseID)

HTML.Text = DirectCast(SqlCmd.ExecuteScalar(),String)
' clean up (close connection etc.)
End Sub
</script>

<asp:Literal ID="HTML" runat="server" />


Each instance requires the DataBaseID to be set.
This assumes a single instance of the html, if you are looping through
the table, do not use this. Don't want
Also, error catching is needed (row doesn't exist, column is null,
DataBaseID is null, etc)

Hope this helps!
 
Back
Top