473,378 Members | 1,493 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,378 software developers and data experts.

striping text of special characters before displaying on webpage

I have this project I am working and I have two tasks

I have a text form that takes in a users input and it is supposed to be
stored in a database and can be viewed from a webpage. I want to be
able to display the text with html special characters like "<", ">" (if
the user typed them in) without it being confused for html code and...

I want to be able to replace a newline character with a "/r/n" whenever
it is used in the text.

Sep 11 '06 #1
2 1571
Hi ebade2000,

String.Replace and Server.HtmlEncode should do the trick.

string s = "<display \r\n me>";
s = Server.HtmlEncode(s); // converts < etc
s = s.Replace("\r\n", "<br>"); // replaces string breaks withhtml
breaks
Response.Write(s);

On Tue, 12 Sep 2006 02:08:12 +0200, <eb*******@gmail.comwrote:
I have this project I am working and I have two tasks

I have a text form that takes in a users input and it is supposed to be
stored in a database and can be viewed from a webpage. I want to be
able to display the text with html special characters like "<", ">" (if
the user typed them in) without it being confused for html code and...

I want to be able to replace a newline character with a "/r/n" whenever
it is used in the text.


--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 12 '06 #2
Thanks that helps a whole lot.

Bade

Morten Wennevik wrote:
Hi ebade2000,

String.Replace and Server.HtmlEncode should do the trick.

string s = "<display \r\n me>";
s = Server.HtmlEncode(s); // converts < etc
s = s.Replace("\r\n", "<br>"); // replaces string breaks with html
breaks
Response.Write(s);

On Tue, 12 Sep 2006 02:08:12 +0200, <eb*******@gmail.comwrote:
I have this project I am working and I have two tasks

I have a text form that takes in a users input and it is supposed to be
stored in a database and can be viewed from a webpage. I want to be
able to display the text with html special characters like "<", ">" (if
the user typed them in) without it being confused for html code and...

I want to be able to replace a newline character with a "/r/n" whenever
it is used in the text.

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 12 '06 #3

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

Similar topics

12
by: who be dat? | last post by:
I'm trying to make a webpage do the following: I want a user to be able to click on a given image (there will be more than one image). Upon clicking a given image, characters specific to that...
23
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite,...
7
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese...
4
by: Kivanc Toker | last post by:
Hi, I've got a problem with displaying texts with turkish characters. There is a website administration system, which is developed using ASP (VBScript) and ADO. This system is being used for...
0
by: news.online.de | last post by:
Hello everybody, probably it's a FAQ but I didn't find anything so far concerning my problem, so I am asking here :-) I am facing the following problem: - I have developed a webservice client...
10
by: korund | last post by:
We can use special characters ('\n') to add line breaks in text in JavaScript popup Alert boxes. there is also few additional special characters: \' single quote \" double quote \&...
25
by: Wim Cossement | last post by:
Hello, I was wondering if there are a few good pages and/or examples on how to process form data correctly for putting it in a MySQL DB. Since I'm not used to using PHP a lot, I already found...
2
by: chike_oji | last post by:
Hello, I am displaying data retrieved from a database as a httpresponse in a webform. I noticed that some characters such as the comma (,), display as special characters in the web browser...
1
by: kashhere | last post by:
Hi one and all, I had came across an error in my iframe In the top of the iframe some special characters are displaying like this "  " can you please guide...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.