Share via

how to convert string to url encode

신승민 1 Reputation point
2022-12-22T15:34:17.767+00:00

bad english sorry..
I want to make auto-search
some internet sites search with url encoded

like "......&query=%BE%C8%B3%E7"

So my problem is
if i click a button, textbox1.text is changed to %XX%XX%XX

please help me

Developer technologies | VB
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 61,191 Reputation points
    2022-12-22T16:07:58.51+00:00

    You didn't mention the framework version you're using. If you're using .NET Framework then System.Web.HttpUtility.UrlEncode will URL encode a string.

       Dim encodedValue As String = HttpUtility.UrlEncode("myvalue")  
    

    If you're using .NET Core/6/7 then System.Web is deprecated so you should use System.Net.WebUtility.UrlEncode instead. There are some differences but none that should really impact the behavior.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.