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

Using html tags pulled from an Access database in ASP page

P: n/a
BCS
I have a web site in which the site administrator can input
information to a database through a web form. The information then
gets displayed on ASP pages. One field is a large text field. Of
course, without html tags, the text gets displayed on the web page as
one long paragraph since the database doesn't store any line breaks or
paragraph breaks. The obvious solution (to me) is to use html tags
like <br> in the input. However, while this information gets stored
in the Access database correctly, when it gets pulled out the page
displays the actual tag on the page. In other words, it actually
converts the "<" to "&lt;" in the html so that it displays as "<" on
the web page.

I'm more used to working with PHP where I didn't have this problem,
and I'm sure there is a simple solution, but I've scoured the web and
my ASP books and can't seem to find the answer.
Jul 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
> like <br> in the input. However, while this information gets stored
in the Access database correctly, when it gets pulled out the page
displays the actual tag on the page. In other words, it actually
converts the "<" to "&lt;" in the html so that it displays as "<" on
the web page.


What is "it"? Can you show the code that causes this bizarre symptom?

Anyway, if you store plain text carriage returns in the database, you don't
need to teach all of your users HTML. Just replace them with HTML carriage
returns when you DISPLAY the data. http://www.aspfaq.com/2188

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #2

P: n/a
BCS
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:<OL**************@TK2MSFTNGP11.phx.gbl>...
like <br> in the input. However, while this information gets stored
in the Access database correctly, when it gets pulled out the page
displays the actual tag on the page. In other words, it actually
converts the "<" to "&lt;" in the html so that it displays as "<" on
the web page.


What is "it"? Can you show the code that causes this bizarre symptom?

Anyway, if you store plain text carriage returns in the database, you don't
need to teach all of your users HTML. Just replace them with HTML carriage
returns when you DISPLAY the data. http://www.aspfaq.com/2188


"it" is simply the text from the access database. All I am doing is
trying to display a text field from the Access database onto a web
page. So maybe it's an Access question. How do you get the Access
database to store the carriage returns from the web form input page?
Jul 19 '05 #3

P: n/a
On 9 Jun 2004 16:34:33 -0700, br**********@hotmail.com (BCS) wrote:
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:<OL**************@TK2MSFTNGP11.phx.gbl>...
> like <br> in the input. However, while this information gets stored
> in the Access database correctly, when it gets pulled out the page
> displays the actual tag on the page. In other words, it actually
> converts the "<" to "&lt;" in the html so that it displays as "<" on
> the web page.


What is "it"? Can you show the code that causes this bizarre symptom?

Anyway, if you store plain text carriage returns in the database, you don't
need to teach all of your users HTML. Just replace them with HTML carriage
returns when you DISPLAY the data. http://www.aspfaq.com/2188


"it" is simply the text from the access database. All I am doing is
trying to display a text field from the Access database onto a web
page. So maybe it's an Access question. How do you get the Access
database to store the carriage returns from the web form input page?


It already does. Except that for display you need HTML carriage
returns, either <P> or <BR> tags. Read the link Aaron posted and do
it.

Jeff

Jul 19 '05 #4

P: n/a
If a user enters a carriage return in a textarea it will be stored - no need
to worry about the how. Keep in mind that you want to separate the content
(what they type in) from the presentation (how or where it gets displayed).
Take whatever they type into the textarea and shove it into the database.
Transform it appropriately depending on what it's used for *after*
retrieving it. If you're displaying it on a web page then you can replace
vbCrLf pairs with <br> tags and Server.HTMLEncode the rest.

Alan

"BCS" <br**********@hotmail.com> wrote in message
news:e1**************************@posting.google.c om...
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message

news:<OL**************@TK2MSFTNGP11.phx.gbl>...
like <br> in the input. However, while this information gets stored
in the Access database correctly, when it gets pulled out the page
displays the actual tag on the page. In other words, it actually
converts the "<" to "&lt;" in the html so that it displays as "<" on
the web page.


What is "it"? Can you show the code that causes this bizarre symptom?

Anyway, if you store plain text carriage returns in the database, you don't need to teach all of your users HTML. Just replace them with HTML carriage returns when you DISPLAY the data. http://www.aspfaq.com/2188


"it" is simply the text from the access database. All I am doing is
trying to display a text field from the Access database onto a web
page. So maybe it's an Access question. How do you get the Access
database to store the carriage returns from the web form input page?

Jul 19 '05 #5

P: n/a
>> What is "it"? Can you show the code that causes this bizarre symptom?

"it" is simply the text from the access database. All I am doing is
trying to display a text field from the Access database onto a web
page. So maybe it's an Access question. How do you get the Access
database to store the carriage returns from the web form input page?


I will repeat what I said before. You don't do anything to store the
carriage returns any differently. You simply replace them with HTML
carriage returns (<br>) when you DISPLAY the text. If you read the link I
posted, you will understand, perhaps, what I mean.

If not, I will ask once more, with a little emphasis on the part of this
equation we need in order to help you.

Can you *****///SHOW THE CODE///***** that causes this bizarre symptom,
instead of describing it with narrative? Do you know how many different
ways one could interpret, "All I am doing is ... "?
Jul 19 '05 #6

P: n/a
BCS
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:<uR*************@tk2msftngp13.phx.gbl>...
What is "it"? Can you show the code that causes this bizarre symptom?


"it" is simply the text from the access database. All I am doing is
trying to display a text field from the Access database onto a web
page. So maybe it's an Access question. How do you get the Access
database to store the carriage returns from the web form input page?


I will repeat what I said before. You don't do anything to store the
carriage returns any differently. You simply replace them with HTML
carriage returns (<br>) when you DISPLAY the text. If you read the link I
posted, you will understand, perhaps, what I mean.

If not, I will ask once more, with a little emphasis on the part of this
equation we need in order to help you.

Can you *****///SHOW THE CODE///***** that causes this bizarre symptom,
instead of describing it with narrative? Do you know how many different
ways one could interpret, "All I am doing is ... "?


Actually, the that was supplied did explain what to do very well and
it did work. I put up the last post just to clarify my original post
since there seemed to be a little confusion about what I was asking.
I probably should have waited until I had a chance to go through the
suggested article (and, yes, I should have provided the code as
requested. I've provdided both the before and after code below so
people with the same problem can quickly see the correction.
ORIGINAL CODE
<%
Dim Conn, cStr, sql, number
number = [response.write request("number")]
set conn = Server.CreateObject("ADODB.Connection")
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("../../db/database1.mdb") & ";"
Conn.Open(cStr)
sql = "SELECT * FROM jobs WHERE ""job number"" = '" &
request("number") & "'"
set rs = conn.execute(sql)
do while not rs.eof
description = rs("description")
response.write(description)
rs.movenext
loop
%>

NEW CODE

<%
Dim Conn, cStr, sql, number
number = [response.write request("number")]
set conn = Server.CreateObject("ADODB.Connection")
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("../../db/database1.mdb") & ";"
Conn.Open(cStr)
sql = "SELECT * FROM jobs WHERE ""job number"" = '" &
request("number") & "'"
set rs = conn.execute(sql)
do while not rs.eof
description = rs("description")
response.write(replace(description, CHR(10), CHR(10) &
"&nbsp;<br>"))

rs.movenext
loop
%>
Jul 19 '05 #7

P: n/a
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:OL**************@TK2MSFTNGP11.phx.gbl...
: Anyway, if you store plain text carriage returns in the database, you
don't
: need to teach all of your users HTML. Just replace them with HTML
carriage
: returns when you DISPLAY the data. http://www.aspfaq.com/2188

chr(10) is a line feed, not a carriage return (chr(13)), so shouldn't you be
using vbCrLf?
response.write(replace(memocolumn, vbCrLf, vbCrLf & "<br />"))

and why is the non-blanking space included?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Jul 19 '05 #8

P: n/a
> chr(10) is a line feed, not a carriage return (chr(13)), so shouldn't you
be
using vbCrLf?
Depending on the source, it's not always a full vbCrLf, and it's not always
paired in the right order. So I picked one of the two.
and why is the non-blanking space included?


It's a non-breaking space, and it is used because if multiple line breaks
were intended, IE et. al. would ignore successive <br>'s, but they won't
ignore successive <br>'s separated by &nbsp;.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #9

P: n/a
What you need to do is to is when you write the 'HTML'
code you want to the page

strText = Rs("memofield")
strText = Replace(strTExt,vbCrLF,"<br>")

This way when the administrator edits the code he/she will
still be able to view the line break in the text area box

HTH

-----Original Message-----
like <br> in the input. However, while this information gets stored in the Access database correctly, when it gets pulled out the page displays the actual tag on the page. In other words, it actually converts the "<" to "<" in the html so that it displays as "<" on the web page.
What is "it"? Can you show the code that causes this

bizarre symptom?
Anyway, if you store plain text carriage returns in the database, you don'tneed to teach all of your users HTML. Just replace them with HTML carriagereturns when you DISPLAY the data. http://www.aspfaq.com/2188
--
http://www.aspfaq.com/
(Reverse address to reply.)
.

Jul 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.