TagBuilder.CreateSanitizedId Method (String, String)
Replaces each invalid character in the tag ID with the specified replacement string.
Namespace: System.Web.Mvc
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
Public Shared Function CreateSanitizedId ( _
originalId As String, _
invalidCharReplacement As String _
) As String
'Usage
Dim originalId As String
Dim invalidCharReplacement As String
Dim returnValue As String
returnValue = TagBuilder.CreateSanitizedId(originalId, _
invalidCharReplacement)
public static string CreateSanitizedId(
string originalId,
string invalidCharReplacement
)
public:
static String^ CreateSanitizedId(
String^ originalId,
String^ invalidCharReplacement
)
static member CreateSanitizedId :
originalId:string *
invalidCharReplacement:string -> string
public static function CreateSanitizedId(
originalId : String,
invalidCharReplacement : String
) : String
Parameters
- originalId
Type: System.String
The ID that might contain characters to replace.
- invalidCharReplacement
Type: System.String
The replacement string.
Return Value
Type: System.String
The sanitized tag ID, or null reference (Nothing in Visual Basic) if originalId is null reference (Nothing in Visual Basic) or empty, or if originalId does not begin with a letter.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | invalidCharReplacement is null reference (Nothing in Visual Basic). |
Remarks
Valid characters consist of letters, numbers, and the hyphen ("-"), underscore ("_"), and colon (":") characters. All other characters are considered invalid. Each invalid character in originalId is replaced with the character specified in the HtmlHelper.IdAttributeDotReplacement property.