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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server.htmlDecode help. Urgent

Status
Not open for further replies.

yuli1104

Programmer
Feb 20, 2002
60
CA
Hello,

In my asp page, I get client reference # input and save to a session variable like this:

strClientRef = server.HTMLEncode(Trim(Request("txtCliRefNo")))
Session(Application("cstCURRCLIREFNO")) = strClientRef

Any character is allowed in the client Reference input and the limit size is 4 . so "123&" is allowed. The session variable maybe used many places that is why we need to make it encoded.

The problem is that later we need to save the value to Database (another page, we can only access the session value). but "123&" becomes to be "123&" which exceeds the maximum size.

Can anybody tell me that how I can decode the session value? I tried server.HTMLDecode(Session(Application("cstCURRCLIREFNO"))), but it seems asp doesn't have HtmlDecode function which asp.net has.

I am not allowed to set another session variable to hold the client input without encoding it.

Please help me, it is very urgent. thanks a million.

Yuli
 
try this decode function.

_________________________________________________________
for the best results to your questions: FAQ333-2924
01001111 01101110 01110000 01101110 01110100
onpnt2.gif
[/sub]
 

Private Function HTMLDecode(byVal encodedstring)
Dim tmp, i
tmp = encodedstring
tmp = Replace( tmp, """, chr(34) )
tmp = Replace( tmp, "<" , chr(60) )
tmp = Replace( tmp, ">" , chr(62) )
tmp = Replace( tmp, "&" , chr(38) )
tmp = Replace( tmp, " ", chr(32) )
For i = 1 to 255
tmp = Replace( tmp, "&#" & i & ";", chr( i ) )
Next
HTMLDecode = tmp
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top