By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,528 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,528 IT Pros & Developers. It's quick & easy.

Problem with pulling page content (mix html and Inline ASP) from SQL database.

P: 1
I'm in the process of self teaching myself and keep encountering the problem of knowing what I want to do, but being unable to ask the correct questions.

In short I am working on a website that will end up being comprised of numerous very similar pages.

I was planning to employ a nested Site Masters storing the actual variable data in a SQL Database.

I am able to pull my HTML code from the data base using the following method.

This code in ASPX

Expand|Select|Wrap|Line Numbers
  1. <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
  2.     <asp:Literal ID="Header_Literal" runat="server"></asp:Literal>
  3. </asp:Content>
  5. <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
  6.     <asp:Literal ID="Body_Literal" runat="server"></asp:Literal>
  7. </asp:Content>
This code in the Codebehind

Expand|Select|Wrap|Line Numbers
  1.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  3.         Dim con As New System.Data.SqlClient.SqlConnection
  4.         con.ConnectionString = "Data Source=XXXXXXXXXXX\SQLEXPRESS;Initial Catalog=master;Integrated Security=True"
  5.         Dim adp As New System.Data.SqlClient.SqlDataAdapter("select * from XXXXXXXXXX", con)
  6.         Dim dt As New System.Data.DataTable
  7.         adp.Fill(dt)
  9.         Header_Literal.Text = dt.Rows(0).Item("Meta_Tags")
  10.         Body_Literal.Text = dt.Rows(0).Item("Page_Title")
  12.     End Sub
The Literal with ID=Header_Literal works perfectly because it is receiving plain HTML from the SQL table.

The Literal ID=Body_Literal gets data, but it is comprised of html and an Inline code element. The HTML works, but the Inline code is being ignored.

I am guessing that this is a problem with me using the Literal control, but I am unclear what I should be using instead.

The content is plain text and the Inline was a calling a codebehind element to mask my email address.

What should I be doing here. Or just as valuable what should I be searching for to learn this on my own?
Jul 19 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.