ClientScriptManager.RegisterExpandoAttribute 메서드

정의

이름/값 쌍을 지정된 컨트롤의 사용자 지정(expando) 특성으로 등록합니다.

오버로드

Name Description
RegisterExpandoAttribute(String, String, String)

컨트롤 ID, 특성 이름 및 특성 값이 지정된 경우 이름/값 쌍을 지정된 컨트롤의 사용자 지정(expando) 특성으로 등록합니다.

RegisterExpandoAttribute(String, String, String, Boolean)

컨트롤 ID, 특성 이름, 특성 값 및 특성 값을 인코딩할지 여부를 나타내는 부울 값을 지정한 컨트롤의 사용자 지정(expando) 특성으로 이름/값 쌍을 등록합니다.

RegisterExpandoAttribute(String, String, String)

컨트롤 ID, 특성 이름 및 특성 값이 지정된 경우 이름/값 쌍을 지정된 컨트롤의 사용자 지정(expando) 특성으로 등록합니다.

public:
 void RegisterExpandoAttribute(System::String ^ controlId, System::String ^ attributeName, System::String ^ attributeValue);
public void RegisterExpandoAttribute(string controlId, string attributeName, string attributeValue);
member this.RegisterExpandoAttribute : string * string * string -> unit
Public Sub RegisterExpandoAttribute (controlId As String, attributeName As String, attributeValue As String)

매개 변수

controlId
String

Control 사용자 지정 특성이 포함된 페이지의 페이지입니다.

attributeName
String

등록할 사용자 지정 특성의 이름입니다.

attributeValue
String

사용자 지정 특성의 값입니다.

설명

이 메서드는 RegisterExpandoAttribute 이름/값 쌍을 지정된 에 대한 사용자 지정(expando) 특성으로 등록합니다 Control. expando 특성은 렌더링된 컨트롤의 태그에 대한 XHTML 호환성을 유지하기 위해 JavaScript에서 동적으로 설정됩니다. 사용자 지정(expando) 특성 값의 따옴표 및 백슬라이스는 이스케이프됩니다. 따옴표와 백슬라이시를 이스케이프하지 않으려면 오버로드 메서드를 RegisterExpandoAttribute 호출하고 매개 변수를 encodefalse.로 설정합니다.

expando 특성을 찾을 수 없거나 expando 특성을 추가할 컨트롤을 찾을 수 없는 경우 클라이언트 스크립트는 계속 내보내지만 컨트롤에는 영향을 미치지 않습니다.

추가 정보

적용 대상

RegisterExpandoAttribute(String, String, String, Boolean)

컨트롤 ID, 특성 이름, 특성 값 및 특성 값을 인코딩할지 여부를 나타내는 부울 값을 지정한 컨트롤의 사용자 지정(expando) 특성으로 이름/값 쌍을 등록합니다.

public:
 void RegisterExpandoAttribute(System::String ^ controlId, System::String ^ attributeName, System::String ^ attributeValue, bool encode);
public void RegisterExpandoAttribute(string controlId, string attributeName, string attributeValue, bool encode);
member this.RegisterExpandoAttribute : string * string * string * bool -> unit
Public Sub RegisterExpandoAttribute (controlId As String, attributeName As String, attributeValue As String, encode As Boolean)

매개 변수

controlId
String

Control 사용자 지정 특성이 포함된 페이지의 페이지입니다.

attributeName
String

등록할 사용자 지정 특성의 이름입니다.

attributeValue
String

사용자 지정 특성의 값입니다.

encode
Boolean

등록할 사용자 지정 특성을 인코딩할지 여부를 나타내는 부울 값입니다.

예제

다음 코드 예제에서는 클래스의 메서드를 RegisterExpandoAttribute 사용 하는 방법을 보여 줍니다 ClientScriptManager . 렌더링된 페이지의 클라이언트 스크립트는 요소의 title<span> 특성을 설정합니다.

<%@ Page Language="C#"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
  public void Page_Load(Object sender, EventArgs e)
  {        
    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;
    
    // Register an expando attribute.
    cs.RegisterExpandoAttribute("Message", "title", "New title from client script.", true);
    
  }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ClientScriptManager Example</title>
  </head>
  <body>
     <form    id="Form1"
            runat="server">
     <span  id="Message" 
            title="Title to be replaced.">
            Place your mouse over this text to see the title.
     </span>           
     </form>
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        
    ' Get a ClientScriptManager reference from the Page class.
    Dim cs As ClientScriptManager = Page.ClientScript
    
    ' Register an expando attribute.
    cs.RegisterExpandoAttribute("Message", "title", "New title from client script.", True)    
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>ClientScriptManager Example</title>
  </head>
  <body>
     <form    id="Form1"
            runat="server">
     <span  id="Message" 
            title="Title to be replaced.">
            Place your mouse over this text to see the title.
     </span>
     </form>
  </body>
</html>

설명

이 메서드는 RegisterExpandoAttribute 이름/값 쌍을 지정된 에 대한 사용자 지정(expando) 특성으로 등록합니다 Control. expando 특성은 렌더링된 컨트롤의 태그에 대한 XHTML 호환성을 유지하기 위해 JavaScript에서 동적으로 설정됩니다. encode expando 특성 값에서 따옴표와 백슬라이시를 이스케이프해야 하는 경우 매개 변수 true 를 설정합니다.

expando 특성을 찾을 수 없거나 expando 특성을 추가할 컨트롤을 찾을 수 없는 경우 클라이언트 스크립트는 계속 내보내지만 컨트롤에는 영향을 미치지 않습니다.

추가 정보

적용 대상