HtmlTextWriter.WriteEncodedUrlParameter(String) 方法

定义

对请求的设备的指定 URL 参数进行编码,然后将它写入到输出流。Encodes the specified URL parameter for the requesting device, and then writes it to the output stream.

public:
 virtual void WriteEncodedUrlParameter(System::String ^ urlText);
public virtual void WriteEncodedUrlParameter (string urlText);
abstract member WriteEncodedUrlParameter : string -> unit
override this.WriteEncodedUrlParameter : string -> unit
Public Overridable Sub WriteEncodedUrlParameter (urlText As String)

参数

urlText
String

要进行编码并写入到输出流的 URL 参数字符串。The URL parameter string to encode and write to the output stream.

示例

下面的代码示例演示如何使用 WriteEncodedUrlParameter 方法,该方法生成以下输出:The following code example shows how to use the WriteEncodedUrlParameter method, which generates the following output:

ID%3dCity+State

// Assign a value to a string variable
// and encode it to a page as a 
// URL parameter.      
param = "ID=City State";
writer.WriteBreak();
writer.WriteEncodedUrlParameter(param);
' Assign a value to a string variable
' and encode it to a page as a 
' URL parameter.      
param = "ID=City State"
writer.WriteBreak()
writer.WriteEncodedUrlParameter(param)

注解

URL 的参数部分中的空格编码为加号 (+) ,等号 (=) 编码为 %3dSpaces in the parameter part of a URL are encoded as plus signs (+), and equal signs (=) are encoded as %3d.

适用于

另请参阅