Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > striping text of special characters before displaying on webpage

Reply
Thread Tools

striping text of special characters before displaying on webpage

 
 
ebade2000@gmail.com
Guest
Posts: n/a
 
      09-12-2006
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.

 
Reply With Quote
 
 
 
 
Morten Wennevik
Guest
Posts: n/a
 
      09-12-2006
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, <(E-Mail Removed)> wrote:

> 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]
 
Reply With Quote
 
 
 
 
ebade2000@gmail.com
Guest
Posts: n/a
 
      09-12-2006
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, <(E-Mail Removed)> wrote:
>
> > 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]


 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collecting details from router, striping info, map and regex. Example. johngnub Perl Misc 1 04-10-2007 08:45 PM
Table row striping johkar Javascript 8 06-22-2006 11:14 AM
striping HTML tags from string, but leaving paragraph formatting Kevin Blount ASP General 2 12-06-2005 09:49 PM
raid striping with one controller jjw A+ Certification 3 12-30-2004 04:52 PM
raid striping Jason Wheeler A+ Certification 10 08-31-2004 01:11 PM



Advertisments