ClientScriptManager.GetCallbackEventReference 메서드

정의

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다.

오버로드

GetCallbackEventReference(Control, String, String, String)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트 및 컨텍스트가 포함됩니다.

GetCallbackEventReference(Control, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트, 컨텍스트 및 부울 값이 포함됩니다.

GetCallbackEventReference(String, String, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 대상, 인수, 클라이언트 스크립트, 컨텍스트, 오류 처리기 및 부울 값이 포함됩니다.

GetCallbackEventReference(Control, String, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트, 컨텍스트, 오류 처리기 및 부울 값이 포함됩니다.

GetCallbackEventReference(Control, String, String, String)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트 및 컨텍스트가 포함됩니다.

public:
 System::String ^ GetCallbackEventReference(System::Web::UI::Control ^ control, System::String ^ argument, System::String ^ clientCallback, System::String ^ context);
public string GetCallbackEventReference (System.Web.UI.Control control, string argument, string clientCallback, string context);
member this.GetCallbackEventReference : System.Web.UI.Control * string * string * string -> string
Public Function GetCallbackEventReference (control As Control, argument As String, clientCallback As String, context As String) As String

매개 변수

control
Control

클라이언트 콜백을 처리하는 서버 Control입니다. 이 컨트롤에서는 ICallbackEventHandler 인터페이스를 구현하고 RaiseCallbackEvent(String) 메서드를 제공해야 합니다.

argument
String

클라이언트 스크립트에서 서버 RaiseCallbackEvent(String) 메서드를 호출하여 생성됩니다.

clientCallback
String

성공한 서버 이벤트의 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

context
String

콜백을 시작하기 전에 클라이언트에서 계산되는 클라이언트 스크립트입니다. 스크립트 결과는 클라이언트 이벤트 처리기로 다시 전달됩니다.

반환

String

클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.

예외

지정된 Controlnull입니다.

지정한 Control에서 ICallbackEventHandler 인터페이스를 구현하지 않는 경우

예제

다음 코드 예제에서는 두 개의 오버 로드를 사용 하는 방법에 설명 합니다 GetCallbackEventReference 정수 증가 하는 클라이언트 콜백 시나리오에는 메서드.

두 콜백 메커니즘 표시 됩니다. 사용 하는 것의 차이 context 매개 변수입니다. A ReceiveServerData1 클라이언트 콜백 함수를 사용 하 여 제공 된 context 매개 변수입니다. 반면에 ReceiveServerData2 클라이언트 콜백 함수에 정의 된를 <script> 페이지의 블록입니다. A RaiseCallbackEvent 메서드는 전달 되는 값을 증가 하는 서버 처리기 및 GetCallbackResult 메서드를 문자열로 증가 값을 반환 합니다. 경우는 RaiseCallbackEvent 메서드는 오류를 반환 하면 ProcessCallBackError 클라이언트 함수를 호출 합니다.

<%@ Page Language="C#" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

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

<script runat="server">
    
    public int cbCount = 0;
    
    // Define method that processes the callbacks on server.
    public void RaiseCallbackEvent(String eventArgument)
    {
        cbCount = Convert.ToInt32(eventArgument) + 1;
    }

    // Define method that returns callback result.
    public string GetCallbackResult()
    {
        return cbCount.ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        // Define a StringBuilder to hold messages to output.
        StringBuilder sb = new StringBuilder();

        // Check if this is a postback.
        sb.Append("No page postbacks have occurred.");
        if (Page.IsPostBack)
        {
            sb.Append("A page postback has occurred.");
        }

        // Write out any messages.
        MyLabel.Text = sb.ToString();

        // Get a ClientScriptManager reference from the Page class.
        ClientScriptManager cs = Page.ClientScript;

        // Define one of the callback script's context.
        // The callback script will be defined in a script block on the page.
        StringBuilder context1 = new StringBuilder();
        context1.Append("function ReceiveServerData1(arg, context)");
        context1.Append("{");
        context1.Append("Message1.innerText =  arg;");
        context1.Append("value1 = arg;");
        context1.Append("}");

        // Define callback references.
        String cbReference1 = cs.GetCallbackEventReference(this, "arg", 
            "ReceiveServerData1", context1.ToString());
        String cbReference2 = cs.GetCallbackEventReference("'" + 
            Page.UniqueID + "'", "arg", "ReceiveServerData2", "", 
            "ProcessCallBackError", false);
        String callbackScript1 = "function CallTheServer1(arg, context) {" + 
            cbReference1 + "; }";
        String callbackScript2 = "function CallTheServer2(arg, context) {" + 
            cbReference2 + "; }";

        // Register script blocks will perform call to the server.
        cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer1", 
            callbackScript1, true);
        cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer2", 
            callbackScript2, true);

    }
</script>

<script type="text/javascript">
var value1 = 0;
var value2 = 0;
function ReceiveServerData2(arg, context)
{
    Message2.innerText = arg;
    value2 = arg;
}
function ProcessCallBackError(arg, context)
{
    Message2.innerText = 'An error has occurred.';
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="Form1" 
          runat="server">
    <div>
      Callback 1 result: <span id="Message1">0</span>
      <br />
      Callback 2 result: <span id="Message2">0</span>
      <br /> <br />
      <input type="button" 
             value="ClientCallBack1" 
             onclick="CallTheServer1(value1, alert('Increment value'))"/>    
      <input type="button" 
             value="ClientCallBack2" 
             onclick="CallTheServer2(value2, alert('Increment value'))"/>
      <br /> <br />
      <asp:Label id="MyLabel" 
                 runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

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

<script runat="server">
  
    Public cbCount As Integer = 0
    
    ' Define method that processes the callbacks on server.
    Public Sub RaiseCallbackEvent(ByVal eventArgument As String) _
    Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
        
        cbCount = Convert.ToInt32(eventArgument) + 1
        
    End Sub

    ' Define method that returns callback result.
    Public Function GetCallbackResult() _
    As String Implements _
    System.Web.UI.ICallbackEventHandler.GetCallbackResult

        Return cbCount.ToString()
        
    End Function
    
    
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    
        ' Define a StringBuilder to hold messages to output.
        Dim sb As New StringBuilder()
    
        ' Check if this is a postback.
        sb.Append("No page postbacks have occurred.")
        If (Page.IsPostBack) Then
      
            sb.Append("A page postback has occurred.")
      
        End If
    
        ' Write out any messages.
        MyLabel.Text = sb.ToString()
    
        ' Get a ClientScriptManager reference from the Page class.
        Dim cs As ClientScriptManager = Page.ClientScript

        ' Define one of the callback script's context.
        ' The callback script will be defined in a script block on the page.
        Dim context1 As New StringBuilder()
        context1.Append("function ReceiveServerData1(arg, context)")
        context1.Append("{")
        context1.Append("Message1.innerText =  arg;")
        context1.Append("value1 = arg;")
        context1.Append("}")
    
        ' Define callback references.
        Dim cbReference1 As String = cs.GetCallbackEventReference(Me, "arg", _
            "ReceiveServerData1", context1.ToString())
        Dim cbReference2 As String = cs.GetCallbackEventReference("'" & _
            Page.UniqueID & "'", "arg", "ReceiveServerData2", "", "ProcessCallBackError", False)
        Dim callbackScript1 As String = "function CallTheServer1(arg, context) {" + _
            cbReference1 + "; }"
        Dim callbackScript2 As String = "function CallTheServer2(arg, context) {" + _
            cbReference2 + "; }"
    
        ' Register script blocks will perform call to the server.
        cs.RegisterClientScriptBlock(Me.GetType(), "CallTheServer1", _
            callbackScript1, True)
        cs.RegisterClientScriptBlock(Me.GetType(), "CallTheServer2", _
            callbackScript2, True)
    
    End Sub
</script>

<script type="text/javascript">
var value1 = 0;
var value2 = 0;
function ReceiveServerData2(arg, context)
{
    Message2.innerText = arg;
    value2 = arg;
}
function ProcessCallBackError(arg, context)
{
    Message2.innerText = 'An error has occurred.';
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="Form1" 
          runat="server">
    <div>
      Callback 1 result: <span id="Message1">0</span>
      <br />
      Callback 2 result: <span id="Message2">0</span>
      <br /> <br />
      <input type="button" 
             value="ClientCallBack1" 
             onclick="CallTheServer1(value1, alert('Increment value'))"/>    
      <input type="button" 
             value="ClientCallBack2" 
             onclick="CallTheServer2(value2, alert('Increment value'))"/>
      <br /> <br />
      <asp:Label id="MyLabel" 
                 runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

설명

GetCallbackEventReference(Control, String, String, String) 메서드는 페이지의 일반적인 수명 주기의 수정된 된 버전에는 서버는 대역의 콜백을 수행 합니다. 자세한 내용은 포스트백 없이 클라이언트 콜백 구현합니다.

참고

브라우저는 Microsoft Internet Explorer (버전 5.0 이상) 이면 스크립트 콜백 메커니즘 Microsoft.XmlHttp COM 개체를 통해 구현 되 고 ActiveX 컨트롤을 사용 하도록 설정할 브라우저 필요. 다른 브라우저를 브라우저의 로컬 문서 개체 모델 (DOM)를 사용 하 여 XMLHttpRequest은 사용 합니다. 브라우저 클라이언트 콜백은 지원 하는지 여부를 확인 하려면 사용 된 SupportsCallback 속성입니다. 브라우저는 HTTP를 통해 XML을 지원 하는지 여부를 확인 하려면 사용 된 SupportsXmlHttp 속성입니다. 두 속성을 통해 액세스할 수 합니다 Browser 내장 asp.net 속성 Request 개체입니다.

합니다 GetCallbackEventReference 오버 로드는 GetCallbackEventReference 메서드는 동기적으로 XML을 사용 하 여 HTTP를 통해 콜백을 수행 합니다. 데이터를 보낼 때 동기적으로 콜백 시나리오에서 동기 콜백을 즉시 반환 하 고 브라우저를 차단 하지 않습니다. 두 개의 동기 콜백을 없는 브라우저에서 동시에 실행할 수 있습니다. 두 번째 콜백이 하나는 현재 보류 중, 하는 경우 두 번째 동기 콜백 첫 번째 취소 하 고 두 번째 콜백만 반환 됩니다.

데이터를 비동기적으로 전송 하는 오버 로드 중 하나를 사용는 useAsync 매개 변수는 부울 값이이 동작을 제어 합니다. 비동기 시나리오에서 여러 개의 보류 중인 콜백을; 할 수 있습니다. 그러나 반환 하는 순서는 시작 된 순서와 일치 하는 보장 되지 않습니다.

또한이 오버 로드 된 GetCallbackEventReference 에서 생성 된 오류 조건의 경우를 처리할 수 없는 클라이언트 함수를 지정 하는 메서드는 RaiseCallbackEvent 메서드. 클라이언트 오류 콜백 처리기를 지정 하는 오버 로드 중 하나를 사용 합니다 clientErrorCallback 매개 변수입니다.

합니다 GetCallbackEventReference(Control, String, String, String) 메서드는 선택적 문자열 argument 매개 변수는 문자열을 반환 합니다. 전달할 또는 여러 값을 받을 입력의 값을 연결 하거나 문자열을 각각 반환 합니다.

참고

스크립트 콜백 작업 하는 동안 업데이트 해야 하는 페이지 또는 컨트롤 속성의 구현에서 뷰 상태를 사용 하지 마십시오. 속성 페이지 요청을 계속 유지 될 경우에 세션 상태를 사용할 수 있습니다.

추가 정보

적용 대상

GetCallbackEventReference(Control, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트, 컨텍스트 및 부울 값이 포함됩니다.

public:
 System::String ^ GetCallbackEventReference(System::Web::UI::Control ^ control, System::String ^ argument, System::String ^ clientCallback, System::String ^ context, bool useAsync);
public string GetCallbackEventReference (System.Web.UI.Control control, string argument, string clientCallback, string context, bool useAsync);
member this.GetCallbackEventReference : System.Web.UI.Control * string * string * string * bool -> string
Public Function GetCallbackEventReference (control As Control, argument As String, clientCallback As String, context As String, useAsync As Boolean) As String

매개 변수

control
Control

클라이언트 콜백을 처리하는 서버 Control입니다. 이 컨트롤에서는 ICallbackEventHandler 인터페이스를 구현하고 RaiseCallbackEvent(String) 메서드를 제공해야 합니다.

argument
String

클라이언트 스크립트에서 서버 RaiseCallbackEvent(String) 메서드를 호출하여 생성됩니다.

clientCallback
String

성공한 서버 이벤트의 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

context
String

콜백을 시작하기 전에 클라이언트에서 계산되는 클라이언트 스크립트입니다. 스크립트 결과는 클라이언트 이벤트 처리기로 다시 전달됩니다.

useAsync
Boolean

콜백을 비동기적으로 수행하려면 true이고, 동기적으로 수행하려면 false입니다.

반환

String

클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.

예외

지정된 Controlnull입니다.

지정한 Control에서 ICallbackEventHandler 인터페이스를 구현하지 않는 경우

설명

이 오버 로드는 GetCallbackEventReference 메서드를 사용 하려면를 useAsync 매개 변수 값을 설정 하 여 클라이언트 콜백을 비동기적으로 수행할 수 있는 true합니다. 필요가 없는 경우이 메서드의 오버 로드 버전의 useAsync 매개 변수 값을 설정 false 기본적으로 합니다.

이 메서드에 대 한 자세한 내용은 오버 로드에 대 한 설명을 참조 GetCallbackEventReference 메서드.

추가 정보

적용 대상

GetCallbackEventReference(String, String, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 대상, 인수, 클라이언트 스크립트, 컨텍스트, 오류 처리기 및 부울 값이 포함됩니다.

public:
 System::String ^ GetCallbackEventReference(System::String ^ target, System::String ^ argument, System::String ^ clientCallback, System::String ^ context, System::String ^ clientErrorCallback, bool useAsync);
public string GetCallbackEventReference (string target, string argument, string clientCallback, string context, string clientErrorCallback, bool useAsync);
member this.GetCallbackEventReference : string * string * string * string * string * bool -> string
Public Function GetCallbackEventReference (target As String, argument As String, clientCallback As String, context As String, clientErrorCallback As String, useAsync As Boolean) As String

매개 변수

target
String

클라이언트 콜백을 처리하는 서버 Control의 이름입니다. 이 컨트롤에서는 ICallbackEventHandler 인터페이스를 구현하고 RaiseCallbackEvent(String) 메서드를 제공해야 합니다.

argument
String

클라이언트 스크립트에서 서버 RaiseCallbackEvent(String) 메서드를 호출하여 생성됩니다.

clientCallback
String

성공한 서버 이벤트의 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

context
String

콜백을 시작하기 전에 클라이언트에서 계산되는 클라이언트 스크립트입니다. 스크립트 결과는 클라이언트 이벤트 처리기로 다시 전달됩니다.

clientErrorCallback
String

서버 이벤트 처리기에서 오류가 발생할 때 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

useAsync
Boolean

콜백을 비동기적으로 수행하려면 true이고, 동기적으로 수행하려면 false입니다.

반환

String

클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.

예제

다음 코드 예제에서는 두 개의 오버 로드를 사용 하는 방법에 설명 합니다 GetCallbackEventReference 정수 증가 하는 클라이언트 콜백 시나리오에는 메서드.

두 콜백 메커니즘 표시 됩니다. 사용 하는 것의 차이 context 매개 변수입니다. A ReceiveServerData1 클라이언트 콜백 함수를 사용 하 여 제공 된 context 매개 변수입니다. 반면에 ReceiveServerData2 클라이언트 콜백 함수에 정의 된를 <script> 페이지의 블록입니다. A RaiseCallbackEvent 메서드는 전달 되는 값을 증가 하는 서버 처리기 및 GetCallbackResult 메서드를 문자열로 증가 값을 반환 합니다. 경우는 RaiseCallbackEvent 메서드는 오류를 클라이언트 함수 ProcessCallBackError 라고 합니다.

<%@ Page Language="C#" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

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

<script runat="server">
    
    public int cbCount = 0;
    
    // Define method that processes the callbacks on server.
    public void RaiseCallbackEvent(String eventArgument)
    {
        cbCount = Convert.ToInt32(eventArgument) + 1;
    }

    // Define method that returns callback result.
    public string GetCallbackResult()
    {
        return cbCount.ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        // Define a StringBuilder to hold messages to output.
        StringBuilder sb = new StringBuilder();

        // Check if this is a postback.
        sb.Append("No page postbacks have occurred.");
        if (Page.IsPostBack)
        {
            sb.Append("A page postback has occurred.");
        }

        // Write out any messages.
        MyLabel.Text = sb.ToString();

        // Get a ClientScriptManager reference from the Page class.
        ClientScriptManager cs = Page.ClientScript;

        // Define one of the callback script's context.
        // The callback script will be defined in a script block on the page.
        StringBuilder context1 = new StringBuilder();
        context1.Append("function ReceiveServerData1(arg, context)");
        context1.Append("{");
        context1.Append("Message1.innerText =  arg;");
        context1.Append("value1 = arg;");
        context1.Append("}");

        // Define callback references.
        String cbReference1 = cs.GetCallbackEventReference(this, "arg", 
            "ReceiveServerData1", context1.ToString());
        String cbReference2 = cs.GetCallbackEventReference("'" + 
            Page.UniqueID + "'", "arg", "ReceiveServerData2", "", 
            "ProcessCallBackError", false);
        String callbackScript1 = "function CallTheServer1(arg, context) {" + 
            cbReference1 + "; }";
        String callbackScript2 = "function CallTheServer2(arg, context) {" + 
            cbReference2 + "; }";

        // Register script blocks will perform call to the server.
        cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer1", 
            callbackScript1, true);
        cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer2", 
            callbackScript2, true);

    }
</script>

<script type="text/javascript">
var value1 = 0;
var value2 = 0;
function ReceiveServerData2(arg, context)
{
    Message2.innerText = arg;
    value2 = arg;
}
function ProcessCallBackError(arg, context)
{
    Message2.innerText = 'An error has occurred.';
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="Form1" 
          runat="server">
    <div>
      Callback 1 result: <span id="Message1">0</span>
      <br />
      Callback 2 result: <span id="Message2">0</span>
      <br /> <br />
      <input type="button" 
             value="ClientCallBack1" 
             onclick="CallTheServer1(value1, alert('Increment value'))"/>    
      <input type="button" 
             value="ClientCallBack2" 
             onclick="CallTheServer2(value2, alert('Increment value'))"/>
      <br /> <br />
      <asp:Label id="MyLabel" 
                 runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>

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

<script runat="server">
  
    Public cbCount As Integer = 0
    
    ' Define method that processes the callbacks on server.
    Public Sub RaiseCallbackEvent(ByVal eventArgument As String) _
    Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
        
        cbCount = Convert.ToInt32(eventArgument) + 1
        
    End Sub

    ' Define method that returns callback result.
    Public Function GetCallbackResult() _
    As String Implements _
    System.Web.UI.ICallbackEventHandler.GetCallbackResult

        Return cbCount.ToString()
        
    End Function
    
    
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
    
        ' Define a StringBuilder to hold messages to output.
        Dim sb As New StringBuilder()
    
        ' Check if this is a postback.
        sb.Append("No page postbacks have occurred.")
        If (Page.IsPostBack) Then
      
            sb.Append("A page postback has occurred.")
      
        End If
    
        ' Write out any messages.
        MyLabel.Text = sb.ToString()
    
        ' Get a ClientScriptManager reference from the Page class.
        Dim cs As ClientScriptManager = Page.ClientScript

        ' Define one of the callback script's context.
        ' The callback script will be defined in a script block on the page.
        Dim context1 As New StringBuilder()
        context1.Append("function ReceiveServerData1(arg, context)")
        context1.Append("{")
        context1.Append("Message1.innerText =  arg;")
        context1.Append("value1 = arg;")
        context1.Append("}")
    
        ' Define callback references.
        Dim cbReference1 As String = cs.GetCallbackEventReference(Me, "arg", _
            "ReceiveServerData1", context1.ToString())
        Dim cbReference2 As String = cs.GetCallbackEventReference("'" & _
            Page.UniqueID & "'", "arg", "ReceiveServerData2", "", "ProcessCallBackError", False)
        Dim callbackScript1 As String = "function CallTheServer1(arg, context) {" + _
            cbReference1 + "; }"
        Dim callbackScript2 As String = "function CallTheServer2(arg, context) {" + _
            cbReference2 + "; }"
    
        ' Register script blocks will perform call to the server.
        cs.RegisterClientScriptBlock(Me.GetType(), "CallTheServer1", _
            callbackScript1, True)
        cs.RegisterClientScriptBlock(Me.GetType(), "CallTheServer2", _
            callbackScript2, True)
    
    End Sub
</script>

<script type="text/javascript">
var value1 = 0;
var value2 = 0;
function ReceiveServerData2(arg, context)
{
    Message2.innerText = arg;
    value2 = arg;
}
function ProcessCallBackError(arg, context)
{
    Message2.innerText = 'An error has occurred.';
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ClientScriptManager Example</title>
</head>
<body>
    <form id="Form1" 
          runat="server">
    <div>
      Callback 1 result: <span id="Message1">0</span>
      <br />
      Callback 2 result: <span id="Message2">0</span>
      <br /> <br />
      <input type="button" 
             value="ClientCallBack1" 
             onclick="CallTheServer1(value1, alert('Increment value'))"/>    
      <input type="button" 
             value="ClientCallBack2" 
             onclick="CallTheServer2(value2, alert('Increment value'))"/>
      <br /> <br />
      <asp:Label id="MyLabel" 
                 runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

설명

이 오버 로드는 GetCallbackEventReference 메서드를 target 매개 변수 대신 문자열을 Control 매개 변수입니다. 콜백을 포함 하는 문자열 이외의 값으로 다시 이동 하려는 경우이 오버 로드를 사용 하 여를 UniqueID 컨트롤입니다.

또한이 오버 로드 된 GetCallbackEventReference 메서드를 사용 하려면를 useAsyncclientErrorCallback 매개 변수입니다. 합니다 useAsync 매개 변수 값을 설정 하 여 클라이언트 콜백을 비동기적으로 수행할 수 있도록 true입니다. 필요가 없는 경우이 메서드의 오버 로드 버전의 useAsync 매개 변수 값을 설정 false 기본적으로 합니다. clientErrorCallback 매개 변수를 사용 하면 호출 되는 클라이언트 함수의 이름을 정의할 수 있습니다 서버 처리기는 RaiseCallbackEvent 메서드를 오류를 반환 합니다. 필요가 없는 경우이 메서드의 오버 로드 버전을 clientErrorCallback 매개 변수 값을 null로 설정 합니다.

이 메서드에 대 한 자세한 내용은 오버 로드에 대 한 설명을 참조 GetCallbackEventReference 메서드.

추가 정보

적용 대상

GetCallbackEventReference(Control, String, String, String, String, Boolean)

호출될 경우 클라이언트에서 서버 이벤트를 콜백하도록 하는 클라이언트 함수에 대한 참조를 가져옵니다. 이 오버로드된 메서드의 클라이언트 함수에는 지정한 컨트롤, 인수, 클라이언트 스크립트, 컨텍스트, 오류 처리기 및 부울 값이 포함됩니다.

public:
 System::String ^ GetCallbackEventReference(System::Web::UI::Control ^ control, System::String ^ argument, System::String ^ clientCallback, System::String ^ context, System::String ^ clientErrorCallback, bool useAsync);
public string GetCallbackEventReference (System.Web.UI.Control control, string argument, string clientCallback, string context, string clientErrorCallback, bool useAsync);
member this.GetCallbackEventReference : System.Web.UI.Control * string * string * string * string * bool -> string
Public Function GetCallbackEventReference (control As Control, argument As String, clientCallback As String, context As String, clientErrorCallback As String, useAsync As Boolean) As String

매개 변수

control
Control

클라이언트 콜백을 처리하는 서버 Control입니다. 이 컨트롤에서는 ICallbackEventHandler 인터페이스를 구현하고 RaiseCallbackEvent(String) 메서드를 제공해야 합니다.

argument
String

클라이언트 스크립트에서 서버 RaiseCallbackEvent(String) 메서드로 전달되는 인수입니다.

clientCallback
String

성공한 서버 이벤트의 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

context
String

콜백을 시작하기 전에 클라이언트에서 계산되는 클라이언트 스크립트입니다. 스크립트 결과는 클라이언트 이벤트 처리기로 다시 전달됩니다.

clientErrorCallback
String

서버 이벤트 처리기에서 오류가 발생할 때 결과를 받는 클라이언트 이벤트 처리기의 이름입니다.

useAsync
Boolean

콜백을 비동기적으로 수행하려면 true이고, 동기적으로 수행하려면 false입니다.

반환

String

클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.

예외

지정된 Controlnull입니다.

지정한 Control에서 ICallbackEventHandler 인터페이스를 구현하지 않는 경우

설명

이 오버 로드 된 GetCallbackEventReference 메서드를 사용 하려면를 useAsyncclientErrorCallback 매개 변수입니다. 합니다 useAsync 매개 변수 값을 설정 하 여 클라이언트 콜백을 비동기적으로 수행할 수 있도록 true입니다. 필요가 없는 경우이 메서드의 오버 로드 버전의 useAsync 매개 변수 값을 설정 false 기본적으로 합니다. 합니다 clientErrorCallback 매개 변수를 사용 하면 호출 되는 클라이언트 함수의 이름을 정의할 수 있습니다 서버 처리기 (의 RaiseCallbackEvent 메서드) 오류를 반환 합니다. 필요가 없는 경우이 메서드의 오버 로드 버전을 clientErrorCallback 매개 변수 값을 null로 설정 합니다.

이 메서드에 대 한 자세한 내용은 오버 로드에 대 한 설명을 참조 GetCallbackEventReference 메서드.

추가 정보

적용 대상