HtmlTextWriter.EncodeUrl(String) 메서드

정의

지정된 URL의 공백을 "%20"으로 변환하여 URL 인코딩을 최소화합니다.

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

매개 변수

url
String

인코딩할 URL이 포함된 문자열입니다.

반환

String

인코딩된 URL이 포함된 문자열입니다.

예제

다음 코드 예제에서는 메서드를 호출하여 메서드 호출 EncodeUrl 에서 매개 변수 AddAttribute 로 전달되는 URL의 공백을 변환하는 방법을 보여 줍니다.

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

설명

문자의 URL 인코딩은 백분율 기호(%)와 문자에 대한 ISO-Latin 코드 포인트의 2자리 16진수 표현(대/소문자 구분 안 함)으로 구성됩니다. 공간의 16진수 표현은 20입니다.

적용 대상

추가 정보