Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTMLEncode does not work for me 1

Status
Not open for further replies.

developer155

Programmer
Joined
Jan 21, 2004
Messages
512
Location
US
Hello, I need a function that would encode a string to HTML friendly format, like this:
INPUT: "This is a string,this is a string"
OUTPUT "This+is+a+string%2C+this+is+a+string"

Server.HTMLEncode but it does nto work(it returns the same string, "This is a test". Is there an alternative?

here is my code

String TestString ="This is a string,this is a string";
StringWriter writer = new StringWriter();
Server.HtmlEncode(TestString, writer);
String EncodedString = writer.ToString();

RETURNS "This is a string,this is a string", so the same thing


thanks
 
I am not sure why that does not work

Use Server.UrlEncode(TestString, writer);

That will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top