server.htmlencodeandserver.urlencodeareverycommonfunctionsusedbyaspdevelopers.well,asyoumayhaveguessed,thesetwofunctionshaveasp.netcounterparts.htmlencodeandurlencode(noticecase)arepartofthesystem.web.httputilitynamespace.
hereisthedemo
urlencode.asp?test=1&test1=2
urlencode.asp%3ftest%3d1%26test1%3d2
thisisatest&hopefullyitworks!
thisisatest&hopefullyitworks!
**********************************
hereisthecode:
**********************************
htmlencodeandurlencodetheasp.netwaysubpage_load(senderasobject,easeventargs)
assignourtesturltoavariable,assignthevariabletoour
labelcontrol
dimstrurltextasstring="urlencode.asp?test=1&test1=2"
strurl.text=strurltext
encodethetesturl,assignittoavariable,assignthe
variabletoourlabelcontrol
dimstrurlencodetextasstring=urlencode(strurltext)
strurlencode.text=strurlencodetext
assignourtesturltoavariable,assignthevariabletoour
labelcontrol
dimstrhtmltextasstring="
thisisatest&hopefullyit
works!"
strhtml.text=strhtmltext
encodethetesthtml,assignittoavariable,assignthe
variabletoourlabelcontrol
dimstrhtmlencodetextasstring=htmlencode(strhtmltext)
strhtmlencode.text=strhtmlencodetext
endsub