Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 01:44 PM
BCS
Guest
 
Posts: n/a
Default Using html tags pulled from an Access database in ASP page

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.
  #2  
Old July 19th, 2005, 01:44 PM
Aaron [SQL Server MVP]
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

> like <br> in the input. However, while this information gets stored[color=blue]
> 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.[/color]

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.)


  #3  
Old July 19th, 2005, 01:44 PM
BCS
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:<OLKwEYkTEHA.1508@TK2MSFTNGP11.phx.gbl>...[color=blue][color=green]
> > 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.[/color]
>
> 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[/color]

"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?
  #4  
Old July 19th, 2005, 01:45 PM
Jeff Cochran
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

On 9 Jun 2004 16:34:33 -0700, bruce_schaaf@hotmail.com (BCS) wrote:
[color=blue]
>"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:<OLKwEYkTEHA.1508@TK2MSFTNGP11.phx.gbl>...[color=green][color=darkred]
>> > 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.[/color]
>>
>> 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[/color]
>
>"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?[/color]

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

  #5  
Old July 19th, 2005, 01:45 PM
Alan Howard
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

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" <bruce_schaaf@hotmail.com> wrote in message
news:e162e1fd.0406091534.566eb0ff@posting.google.c om...[color=blue]
> "Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message[/color]
news:<OLKwEYkTEHA.1508@TK2MSFTNGP11.phx.gbl>...[color=blue][color=green][color=darkred]
> > > 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.[/color]
> >
> > 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[/color][/color]
don't[color=blue][color=green]
> > need to teach all of your users HTML. Just replace them with HTML[/color][/color]
carriage[color=blue][color=green]
> > returns when you DISPLAY the data. http://www.aspfaq.com/2188[/color]
>
> "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?[/color]


  #6  
Old July 19th, 2005, 01:45 PM
Aaron [SQL Server MVP]
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

>> What is "it"? Can you show the code that causes this bizarre symptom?[color=blue]
>
> "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?[/color]

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 ... "?


  #7  
Old July 19th, 2005, 01:46 PM
BCS
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:<uRYQAfoTEHA.556@tk2msftngp13.phx.gbl>...[color=blue][color=green][color=darkred]
> >> What is "it"? Can you show the code that causes this bizarre symptom?[/color]
> >
> > "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?[/color]
>
> 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 ... "?[/color]

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
%>
  #8  
Old July 19th, 2005, 01:46 PM
Roland Hall
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message
news:OLKwEYkTEHA.1508@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




  #9  
Old July 19th, 2005, 01:46 PM
Aaron [SQL Server MVP]
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

> chr(10) is a line feed, not a carriage return (chr(13)), so shouldn't you[color=blue]
> be
> using vbCrLf?[/color]

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.
[color=blue]
> and why is the non-blanking space included?[/color]

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.)


  #10  
Old July 19th, 2005, 01:49 PM
Stuart Grant
Guest
 
Posts: n/a
Default Re: Using html tags pulled from an Access database in ASP page

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

[color=blue]
>-----Original Message-----[color=green]
>> like <br> in the input. However, while this[/color][/color]
information gets stored[color=blue][color=green]
>> in the Access database correctly, when it gets pulled[/color][/color]
out the page[color=blue][color=green]
>> displays the actual tag on the page. In other words,[/color][/color]
it actually[color=blue][color=green]
>> converts the "<" to "<" in the html so that it displays[/color][/color]
as "<" on[color=blue][color=green]
>> the web page.[/color]
>
>What is "it"? Can you show the code that causes this[/color]
bizarre symptom?[color=blue]
>
>Anyway, if you store plain text carriage returns in the[/color]
database, you don't[color=blue]
>need to teach all of your users HTML. Just replace them[/color]
with HTML carriage[color=blue]
>returns when you DISPLAY the data.[/color]
http://www.aspfaq.com/2188[color=blue]
>
>--
>http://www.aspfaq.com/
>(Reverse address to reply.)
>
>
>.
>[/color]
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles