none
urlEncode

    Question

  • Hi,

    I'm working with Windows Forms in VS.NET 05. I'm trying to use HttpUtility.urlEncode from System.Web. But because i'm working with winforms I can't use urlEncode. It doesn't exists for winforms. Does anybody knows a good equivalent?

    thanks
    Wednesday, May 10, 2006 7:33 AM

Answers

  • Actually, you can use System.Web.HttpUtility from a Windows forms application.

    You'll just need to add a reference to System.Web in your project.

    In the Project Explorer, right click on references and choose 'Add reference'

    Select the 'System.Web' namespace

    Now, in your form,  you can just use the following code

    private void btnEncode_Click(object sender, EventArgs e) {

    //will display 'this+is+a+test'

    MessageBox.Show(System.Web.HttpUtility.UrlEncode("this is a test"));

    }

    Wednesday, May 10, 2006 7:59 AM