473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using html tags pulled from an Access database in ASP page

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
9 2128
> 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
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
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
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
>> 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
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
"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
> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kathryn | last post by:
Good morning! I am having a problem with a span. I have items, of which I only want to show the first X characters on the screen. If the user prints the page, I want the entire item to print....
8
by: Kathleen Dollard | last post by:
Hi, Oleg's answer about attribute value templates led me to look back at a different problem, and wonder if someone else had solved it. I want to output an ASP.NET page. Thus I need to output...
21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
5
by: samuelberthelot | last post by:
Hi, I get this exception when I use a themed css file. In my web.config file I have: <pages theme="dRise"> and the trouble page is a master page : <% Response.Write(Header)%> <form...
9
by: Nathan Sokalski | last post by:
I am using ASP.NET 2.0's ImageMap Control to create 2 imagemaps, one directly below the other. When I do this a thin blank space appears between them. After several days of frustration I realized...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
11
by: S N | last post by:
how to print apostrophe character ' and double quote " in asp using vbscript. my code using response.write replaces " character with inverted question mark. please help
0
by: Lars Eighner | last post by:
In our last episode, <004f629c$0$10265$c3e8da3@news.astraweb.com>, the lovely and talented mark4asp broadcast on comp.infosystems.www.authoring.html: I have not done this, not even on...
2
by: anu b | last post by:
Now i am sending email to my friend using session variable... but my code is as below private bool SendEmail(string email) { try
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.