473,387 Members | 1,844 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.

Format text from db into HTML text

Hi all,

Firstly, sorry for the simple question, as i'm sure i'm missing something
obvious.

I have a text field (varchar) I am reading from an SQL db, into a string
variable, in .NET

I am then assigning this string variable to an HTML control, either Label or
Textbox, depending on the edit situation.

The problem I am getting is that the text that is displayed on the web page
does not show the text formatting of the original text, i.e. carriage
returns etc.

So the q. how do I convert the text string in .NET to the html formatted
string to be displayed on the web page, and how do I then reverse that
process once the web user has edited the text?

And while I'm on the subject, is there an easy way to display RTF text in an
HTML control?

Thanks in Advance.
R.
Nov 19 '05 #1
3 1467
Rigga, I don't think there's anything totally obvious--just do the
replacement yourself, e.g. string.replace \n (vbcrlf) with <br> and vice
versa.

Bill

"Rigga" wrote:
Hi all,

Firstly, sorry for the simple question, as i'm sure i'm missing something
obvious.

I have a text field (varchar) I am reading from an SQL db, into a string
variable, in .NET

I am then assigning this string variable to an HTML control, either Label or
Textbox, depending on the edit situation.

The problem I am getting is that the text that is displayed on the web page
does not show the text formatting of the original text, i.e. carriage
returns etc.

So the q. how do I convert the text string in .NET to the html formatted
string to be displayed on the web page, and how do I then reverse that
process once the web user has edited the text?

And while I'm on the subject, is there an easy way to display RTF text in an
HTML control?

Thanks in Advance.
R.

Nov 19 '05 #2
P.S. The textbox formatting is done by setting mode to Multiline obviously,
It's the Label text I am more interested in solving, so that as well as
retaining the formatting of the original text in terms of carriage returns
etc. the text can also be displayed in the visual style of the appropriate
web page.

Thanks.
R.

"Rigga" <s@v.c> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
Hi all,

Firstly, sorry for the simple question, as i'm sure i'm missing something
obvious.

I have a text field (varchar) I am reading from an SQL db, into a string
variable, in .NET

I am then assigning this string variable to an HTML control, either Label
or Textbox, depending on the edit situation.

The problem I am getting is that the text that is displayed on the web
page does not show the text formatting of the original text, i.e. carriage
returns etc.

So the q. how do I convert the text string in .NET to the html formatted
string to be displayed on the web page, and how do I then reverse that
process once the web user has edited the text?

And while I'm on the subject, is there an easy way to display RTF text in
an HTML control?

Thanks in Advance.
R.

Nov 19 '05 #3
Hello
If the text that you bring form DB is not in HTML format you will need to
replace "carriage returns" with "<p>" or "<br>" using: lblTest=
replace(string, char(13), "<br>")
Regards
Saeid Kdaimati

"Rigga" wrote:
P.S. The textbox formatting is done by setting mode to Multiline obviously,
It's the Label text I am more interested in solving, so that as well as
retaining the formatting of the original text in terms of carriage returns
etc. the text can also be displayed in the visual style of the appropriate
web page.

Thanks.
R.

"Rigga" <s@v.c> wrote in message
news:42***********************@ptn-nntp-reader02.plus.net...
Hi all,

Firstly, sorry for the simple question, as i'm sure i'm missing something
obvious.

I have a text field (varchar) I am reading from an SQL db, into a string
variable, in .NET

I am then assigning this string variable to an HTML control, either Label
or Textbox, depending on the edit situation.

The problem I am getting is that the text that is displayed on the web
page does not show the text formatting of the original text, i.e. carriage
returns etc.

So the q. how do I convert the text string in .NET to the html formatted
string to be displayed on the web page, and how do I then reverse that
process once the web user has edited the text?

And while I'm on the subject, is there an easy way to display RTF text in
an HTML control?

Thanks in Advance.
R.


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
0
by: Klaus Bonadt | last post by:
I would like to parse an email, which I receive from a pop3 account. While the subject and the sender's email address are probably easy to determine, the body seems to be more difficult because of...
0
by: Klaus Bonadt | last post by:
I would like to parse an email, which I receive from a pop3 account. While the subject and the sender's email address are probably easy to determine, the body seems to be more difficult because of...
16
by: Alexio | last post by:
Am new to javascript. I need to format the currency in the as numbers are entered in textboxes. I can format the currency in the calculations and display in the totals but can not figure out how to...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.