Monday, March 26, 2012

HTML file from database to user interface

Here is some sample/psuedo code. This should give you a good idea of
how to implement this.

<%@dotnet.itags.org. Control ClassName="DataBaseHtmlLiteral" %>

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

Sub OnPreRender
' create sql connection and command
SqlCmd = "Select TOP 1 [Table].[html] from [Table] WHERE [Table].
[IDField] = @dotnet.itags.org.ID"
SqlCmd.Parameters.add("@dotnet.itags.org.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!

No comments:

Post a Comment