添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. I need to convert a plain text string into its URL form by encoding it.
This can be done in ASP.NET via the System.Web.HttpUtility.URLencode("string here") function, however an equivalent does not seem to exist in vb.NET framework 4.0
Any ideas on how to accomplish this? It still exists... same place as it has always been:
http://msdn.microsoft.com/en-us/library/4fkewx0t.aspx
* I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
* I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
* How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
* How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
* I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
* I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
* How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
* How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
The HttpUtility class is a member of the System.Web namespace and is declared in the System.Web.dll assembly, just as the documentation says. As such, to use it you must reference that assembly and, to use it unqualified, you must import that namespace. This worked fine for me:
Code:
Imports System.Web
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MessageBox.Show(HttpUtility.UrlEncode("I want to encode this."))
    End Sub
End Class
Note that, in VS 2010, a WinForms app targets the .NET Framework 4.0 Client Profile by default. System.Web.dll is, understandably, not part of the client profile, so it can;t be referenced by default. You must change the target Framework in the Advanced Compile Options to the full .NET 4.0 to access it. I haven't got VB Express installed to check but I would think that you'd have to have enabled advanced options to be able to do that.
Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.