ClientScriptManager.GetCallbackEventReference 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
호출될 때 서버 이벤트에 대한 클라이언트 호출을 다시 시작하는 클라이언트 함수에 대한 참조를 가져옵니다.
오버로드
| Name | Description |
|---|---|
| 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) 제공해야 합니다.
- clientCallback
- String
성공한 서버 이벤트의 결과를 수신하는 클라이언트 이벤트 처리기의 이름입니다.
- context
- String
콜백을 시작하기 전에 클라이언트에서 평가되는 클라이언트 스크립트입니다. 스크립트의 결과는 클라이언트 이벤트 처리기에 다시 전달됩니다.
반환
클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.
예외
지정된 값 Control 은 .입니다 null.
Control 지정된 인터페이스를 ICallbackEventHandler 구현하지 않습니다.
예제
다음 코드 예제에서는 정수를 증가 하는 클라이언트 콜백 시나리오에서 메서드의 GetCallbackEventReference 두 오버 로드를 사용 하는 방법을 보여 줍니다.
두 가지 콜백 메커니즘이 표시됩니다. 둘 사이의 차이점은 매개 변수를 사용하는 것입니다 context .
ReceiveServerData1 클라이언트 콜백 함수는 매개 변수를 context 사용하여 제공됩니다. 반면 클라이언트 ReceiveServerData2 콜백 함수는 페이지의 블록에 정의됩니다 <script> .
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) 페이지의 일반 수명 주기의 수정된 버전인 서버에 대한 대역 외 콜백을 수행합니다. 자세한 내용은 Postback 없이 클라이언트 콜백 구현을 참조하세요.
메모
브라우저가 Microsoft Internet Explorer(버전 5.0 이상)인 경우 스크립트 콜백 메커니즘은 Microsoft.XmlHttp COM 개체를 통해 구현되며 ActiveX 컨트롤을 실행하도록 브라우저를 설정해야 합니다. 다른 브라우저의 경우 브라우저의 로컬 DOM(문서 개체 모델)을 사용하는 XMLHttpRequest가 사용됩니다. 브라우저에서 클라이언트 콜백을 지원하는지 확인하려면 이 속성을 사용합니다 SupportsCallback . 브라우저에서 HTTP를 통해 XML을 지원하는지 확인하려면 이 속성을 사용합니다 SupportsXmlHttp . 두 속성 모두 내장 ASP.NET 개체의 속성을 통해 Browser 액세스할 수 Request 있습니다.
GetCallbackEventReference 메서드의 GetCallbackEventReference 오버로드는 HTTP를 통해 XML을 사용하여 동기적으로 콜백을 수행합니다. 콜백 시나리오에서 데이터를 동기적으로 보내는 경우 동기 콜백은 즉시 반환되며 브라우저를 차단하지 않습니다. 두 개의 동기 콜백 콜백은 브라우저에서 동시에 실행할 수 없습니다. 현재 보류 중인 동안 두 번째 동기 콜백이 발생하는 경우 두 번째 동기 콜백은 첫 번째 콜백을 취소하고 두 번째 콜백만 반환합니다.
데이터를 비동기적으로 보내려면 이 동작을 제어하는 부울 값인 매개 변수를 사용하는 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) 제공해야 합니다.
- clientCallback
- String
성공한 서버 이벤트의 결과를 수신하는 클라이언트 이벤트 처리기의 이름입니다.
- context
- String
콜백을 시작하기 전에 클라이언트에서 평가되는 클라이언트 스크립트입니다. 스크립트의 결과는 클라이언트 이벤트 처리기에 다시 전달됩니다.
- useAsync
- Boolean
true 콜백을 비동기적으로 수행하려면 false 콜백을 동기적으로 수행합니다.
반환
클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.
예외
지정된 값 Control 은 .입니다 null.
Control 지정된 인터페이스를 ICallbackEventHandler 구현하지 않습니다.
설명
메서드의 GetCallbackEventReference 이 오버로드에는 값을 true으로 설정하여 클라이언트 콜백을 비동기적으로 수행할 수 있는 매개 변수가 필요합니다useAsync. 매개 변수가 필요하지 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) 제공해야 합니다.
- clientCallback
- String
성공한 서버 이벤트의 결과를 수신하는 클라이언트 이벤트 처리기의 이름입니다.
- context
- String
콜백을 시작하기 전에 클라이언트에서 평가되는 클라이언트 스크립트입니다. 스크립트의 결과는 클라이언트 이벤트 처리기에 다시 전달됩니다.
- clientErrorCallback
- String
서버 이벤트 처리기에서 오류가 발생할 때 결과를 수신하는 클라이언트 이벤트 처리기의 이름입니다.
- useAsync
- Boolean
true 콜백을 비동기적으로 수행하려면 false 콜백을 동기적으로 수행합니다.
반환
클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.
예제
다음 코드 예제에서는 정수를 증가 하는 클라이언트 콜백 시나리오에서 메서드의 GetCallbackEventReference 두 오버 로드를 사용 하는 방법을 보여 줍니다.
두 가지 콜백 메커니즘이 표시됩니다. 둘 사이의 차이점은 매개 변수를 사용하는 것입니다 context .
ReceiveServerData1 클라이언트 콜백 함수는 매개 변수를 context 사용하여 제공됩니다. 반면 클라이언트 ReceiveServerData2 콜백 함수는 페이지의 블록에 정의됩니다 <script> .
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 사용합니다target. 콜백이 컨트롤을 포함하는 문자열이 아닌 다른 항목으로 돌아가려면 이 오버로드를 UniqueID 사용합니다.
또한 메서드의 GetCallbackEventReference 이 오버로드에는 a useAsync 및 매개 변수가 clientErrorCallback 필요합니다. 매개 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 콜백을 동기적으로 수행합니다.
반환
클라이언트 콜백을 호출하는 클라이언트 함수의 이름입니다.
예외
지정된 값 Control 은 .입니다 null.
Control 지정된 인터페이스를 ICallbackEventHandler 구현하지 않습니다.
설명
메서드의 GetCallbackEventReference 이 오버로드에는 a useAsync 및 매개 변수가 clientErrorCallback 필요합니다. 매개 useAsync 변수를 사용하면 값을 .로 설정하여 클라이언트 콜백을 비동기적으로 수행할 수 있습니다 true. 매개 변수가 필요하지 useAsync 않은 이 메서드의 오버로드 버전은 기본적으로 값을 false 설정합니다. 매개 clientErrorCallback 변수를 사용하면 서버 처리기(메서드)가 오류를 반환하는 경우 호출되는 클라이언트 함수의 RaiseCallbackEvent 이름을 정의할 수 있습니다. 매개 변수가 필요하지 clientErrorCallback 않은 이 메서드의 오버로드 버전은 값을 null로 설정합니다.
이 메서드에 대한 자세한 내용은 오버로드 GetCallbackEventReference 메서드에 대한 비고를 참조하세요.