HtmlTextWriter.EncodeUrl(String) Metoda

Definice

Provádí minimální kódování adresy URL převodem mezer v zadané adrese URL na řetězec %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

Parametry

url
String

Řetězec obsahující adresu URL pro kódování.

Návraty

String

Řetězec obsahující zakódovanou adresu URL.

Příklady

Následující příklad kódu ukazuje, jak volat metodu EncodeUrl pro převod všech mezer v adrese URL, která je předána jako parametr ve AddAttribute volání metody.

// 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

Poznámky

Kódování adresy URL znaku se skládá ze symbolu procenta (%), následované dvoumístným šestnáctkovým znázorněním (nerozlišující malá a velká písmena) ISO-Latin bodu kódu znaku. Šestnáctková reprezentace prostoru je 20.

Platí pro

Viz také