HtmlTextWriter.EncodeUrl(String) Método

Definición

Realiza una codificación de dirección URL mínima convirtiendo espacios en la dirección URL especificada en la cadena "%20".

protected:
 System::String ^ EncodeUrl(System::String ^ url);
protected string EncodeUrl(string url);
member this.EncodeUrl : string -> string
Protected Function EncodeUrl (url As String) As String

Parámetros

url
String

Cadena que contiene la dirección URL que se va a codificar.

Devoluciones

Cadena que contiene la dirección URL codificada.

Ejemplos

En el ejemplo de código siguiente se muestra cómo llamar al EncodeUrl método para convertir los espacios en la dirección URL que se pasa como parámetro en una AddAttribute llamada de método.

// If an <anchor> element is rendered and an href
// attribute has not been defined, call the AddAttribute
// method to add an href attribute
// and set it to http://www.cohowinery.com.
// Use the EncodeUrl method to convert any spaces to %20.
if ( TagKey == HtmlTextWriterTag::A )
{
   if (  !IsAttributeDefined( HtmlTextWriterAttribute::Href ) )
   {
      AddAttribute( "href", EncodeUrl( "http://www.cohowinery.com" ) );
   }
}
// If an <anchor> element is rendered and an href
// attribute has not been defined, call the AddAttribute
// method to add an href attribute
// and set it to http://www.cohowinery.com.
// Use the EncodeUrl method to convert any spaces to %20.
if (TagKey == HtmlTextWriterTag.A)
{
    if (!IsAttributeDefined(HtmlTextWriterAttribute.Href))
    {
        AddAttribute("href", EncodeUrl("http://www.cohowinery.com"));
    }
}
' If an <anchor> element is rendered and an href
' attribute has not been defined, call the AddAttribute
' method to add an href attribute
' and set it to http://www.cohowinery.com.
' Use the EncodeUrl method to convert any spaces to %20.
If TagKey = HtmlTextWriterTag.A Then
    If Not IsAttributeDefined(HtmlTextWriterAttribute.Href) Then
        AddAttribute("href", EncodeUrl("http://www.cohowinery.com"))
    End If
End If

Comentarios

La codificación URL de un carácter consta de un símbolo de porcentaje (%), seguido de la representación hexadecimal de dos dígitos (sin distinción entre mayúsculas y minúsculas) del punto de código de ISO-Latin para el carácter. La representación hexadecimal de un espacio es 20.

Se aplica a

Consulte también