以最簡化的方式將字串轉換為 HTML 編碼的字串。
命名空間: System.Web
組件: System.Web (在 system.web.dll 中)
Public Shared Function HtmlAttributeEncode ( _
s As String _
) As String
Dim s As String
Dim returnValue As String
returnValue = HttpUtility.HtmlAttributeEncode(s)
public static string HtmlAttributeEncode (
string s
)
public:
static String^ HtmlAttributeEncode (
String^ s
)
public static String HtmlAttributeEncode (
String s
)
public static function HtmlAttributeEncode (
s : String
) : String
參數
- s
要編碼的字串。
傳回值
編碼的字串。
HtmlAttributeEncode 方法只會將引號 (")、連字號 (&) 和左角括弧 (<) 轉換成對等的字元實體。它的速度比 HtmlEncode 方法快許多。
HtmlAttributeEncode 方法所產生的字串,僅可用於雙引號括住的屬性 (Attribute)。將 HtmlAttributeEncode 方法與單引號括住的屬性搭配使用時,可能會發生安全性問題。
Windows 98、 Windows 2000 SP4、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
.NET Framework
支援版本:2.0、1.1、1.0