ClientScriptManager.GetCallbackEventReference Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta a um evento servidor.
Sobrecargas
| Name | Description |
|---|---|
| GetCallbackEventReference(Control, String, String, String) |
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta a um evento servidor. A função cliente deste método sobrecarregado inclui um controlo, argumento, script cliente e contexto especificados. |
| GetCallbackEventReference(Control, String, String, String, Boolean) |
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente para este método sobrecarregado inclui um controlo especificado, argumento, script cliente, contexto e valor booleano. |
| GetCallbackEventReference(String, String, String, String, String, Boolean) |
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente deste método sobrecarregado inclui um alvo especificado, argumento, script cliente, contexto, manipulador de erros e valor booleano especificados. |
| GetCallbackEventReference(Control, String, String, String, String, Boolean) |
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente para este método sobrecarregado inclui um controlo especificado, argumento, script cliente, contexto, manipulador de erros e valor booleano especificados. |
GetCallbackEventReference(Control, String, String, String)
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta a um evento servidor. A função cliente deste método sobrecarregado inclui um controlo, argumento, script cliente e contexto especificados.
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
Parâmetros
- control
- Control
O servidor Control que gere o callback do cliente. O controlo deve implementar a ICallbackEventHandler interface e fornecer um RaiseCallbackEvent(String) método.
- argument
- String
Um argumento passado do script cliente para o servidor
RaiseCallbackEvent(String) método.
- clientCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado do evento do servidor bem-sucedido.
- context
- String
O script do cliente que é avaliado no cliente antes de iniciar a chamada de retorno. O resultado do script é transmitido de volta ao gestor de eventos do cliente.
Devoluções
O nome de uma função cliente que invoca o callback do cliente.
Exceções
O Control especificado é null.
O Control especificado não implementa a ICallbackEventHandler interface.
Exemplos
O exemplo de código seguinte demonstra como usar duas sobrecargas do GetCallbackEventReference método num cenário de callback de cliente que incrementa inteiros.
São apresentados dois mecanismos de callback; A diferença entre eles é o uso do context parâmetro. Uma função de ReceiveServerData1 callback do cliente é fornecida usando o context parâmetro. Em contraste, a ReceiveServerData2 função de callback do cliente é definida num <script> bloco na página. Um RaiseCallbackEvent método é o handler do servidor que incrementa o valor que lhe é passado e o GetCallbackResult método devolve o valor incrementado como uma cadeia. Se o RaiseCallbackEvent método devolver um erro, então a ProcessCallBackError função cliente é chamada.
<%@ 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>
Observações
O GetCallbackEventReference(Control, String, String, String) método realiza um callback fora de banda para o servidor, que é uma versão modificada do ciclo de vida normal de uma página. Para mais informações, consulte Implementar Callbacks de Cliente Sem Postbacks.
Note
Quando o navegador está Microsoft Internet Explorer (versão 5.0 ou posterior), o mecanismo de callback de script é implementado através do Microsoft. XmlHttp COM e requer que o navegador esteja configurado para executar controlos ActiveX. Para outros navegadores, é utilizado um XMLHttpRequest usando o Document Object Model (DOM) local do navegador. Para verificar se um navegador suporta callbacks de clientes, utilize a SupportsCallback propriedade. Para verificar se um navegador suporta XML sobre HTTP, use a SupportsXmlHttp propriedade. Ambas as propriedades são acessíveis através da propriedade Browser do objeto intrínseco ASP.NET Request.
A GetCallbackEventReference sobrecarga do GetCallbackEventReference método realiza um callback de forma síncrona usando XML sobre HTTP. Ao enviar dados de forma síncrona num cenário de callback, as callbacks síncronas retornam imediatamente e não bloqueiam o navegador. Nenhuma chamada de retorno de chamada síncrona pode ser executada simultaneamente no navegador. Se um segundo callback síncrono for disparado enquanto um está pendente, o segundo callback síncrono cancela o primeiro e apenas o segundo callback retornará.
Para enviar dados de forma assíncrona, use um dos overloads que assume o useAsync parâmetro, que é um valor booleano que controla este comportamento. No cenário assíncrono, pode haver múltiplas chamadas pendentes; no entanto, a ordem em que regressam não é garantida que corresponda à ordem em que foram iniciados.
Além disso, esta sobrecarga do GetCallbackEventReference método não especifica nenhuma função cliente para lidar com o caso de uma condição de erro gerada pelo RaiseCallbackEvent método. Para especificar um handler de callback de erro do cliente, use um dos overloads que assume o clientErrorCallback parâmetro.
O GetCallbackEventReference(Control, String, String, String) método recebe um parâmetro opcional de cadeia argument e devolve uma cadeia. Para passar ou receber múltiplos valores, concatena valores na cadeia de entrada ou de retorno, respetivamente.
Note
Evite usar o estado da vista na implementação de propriedades de página ou controlo que precisam de ser atualizadas durante operações de callback de script. Se as propriedades forem para sobreviver aos pedidos de página, podes usar o estado da sessão.
Ver também
Aplica-se a
GetCallbackEventReference(Control, String, String, String, Boolean)
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente para este método sobrecarregado inclui um controlo especificado, argumento, script cliente, contexto e valor booleano.
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
Parâmetros
- control
- Control
O servidor Control que gere o callback do cliente. O controlo deve implementar a ICallbackEventHandler interface e fornecer um RaiseCallbackEvent(String) método.
- argument
- String
Um argumento passado do script cliente para o servidor
RaiseCallbackEvent(String) método.
- clientCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado do evento do servidor bem-sucedido.
- context
- String
O script do cliente que é avaliado no cliente antes de iniciar a chamada de retorno. O resultado do script é transmitido de volta ao gestor de eventos do cliente.
- useAsync
- Boolean
true realizar o callback de forma assíncrona; false para realizar o callback de forma síncrona.
Devoluções
O nome de uma função cliente que invoca o callback do cliente.
Exceções
O Control especificado é null.
O Control especificado não implementa a ICallbackEventHandler interface.
Observações
Esta sobrecarga do GetCallbackEventReference método requer um useAsync parâmetro, que permite realizar o callback do cliente de forma assíncrona, definindo o valor para true. As versões de sobrecarga deste método que não requerem o useAsync parâmetro definem o valor por false defeito.
Para mais informações sobre este método, consulte as observações sobre o método de sobrecarga GetCallbackEventReference .
Ver também
Aplica-se a
GetCallbackEventReference(String, String, String, String, String, Boolean)
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente deste método sobrecarregado inclui um alvo especificado, argumento, script cliente, contexto, manipulador de erros e valor booleano especificados.
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
Parâmetros
- target
- String
O nome de um servidor Control que gere o callback do cliente. O controlo deve implementar a ICallbackEventHandler interface e fornecer um RaiseCallbackEvent(String) método.
- argument
- String
Um argumento passado do script cliente para o servidor
RaiseCallbackEvent(String) método.
- clientCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado do evento do servidor bem-sucedido.
- context
- String
O script do cliente que é avaliado no cliente antes de iniciar a chamada de retorno. O resultado do script é transmitido de volta ao gestor de eventos do cliente.
- clientErrorCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado quando ocorre um erro no gestor de eventos do servidor.
- useAsync
- Boolean
true realizar o callback de forma assíncrona; false para realizar o callback de forma síncrona.
Devoluções
O nome de uma função cliente que invoca o callback do cliente.
Exemplos
O exemplo de código seguinte demonstra como usar duas sobrecargas do GetCallbackEventReference método num cenário de callback de cliente que incrementa inteiros.
São apresentados dois mecanismos de callback; A diferença entre eles é o uso do context parâmetro. Uma função de ReceiveServerData1 callback do cliente é fornecida usando o context parâmetro. Em contraste, a ReceiveServerData2 função de callback do cliente é definida num <script> bloco na página. Um RaiseCallbackEvent método é o handler do servidor que incrementa o valor que lhe é passado e o GetCallbackResult método devolve o valor incrementado como uma cadeia. Se o RaiseCallbackEvent método devolver um erro, então a função ProcessCallBackError cliente é chamada.
<%@ 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>
Observações
Esta sobrecarga do GetCallbackEventReference método utiliza um target parâmetro de string em vez de um Control parâmetro. Usa esta sobrecarga quando quiseres que o callback volte para algo diferente de uma string contendo o UniqueID controlo.
Além disso, esta sobrecarga do GetCallbackEventReference método requer um useAsync e um clientErrorCallback parâmetro. O useAsync parâmetro permite realizar o callback do cliente de forma assíncrona, definindo o valor para true. As versões de sobrecarga deste método que não requerem o useAsync parâmetro definem o valor por false defeito. O clientErrorCallback parâmetro permite definir o nome da função cliente que é chamada se o handler do servidor, o RaiseCallbackEvent método, devolver um erro. As versões de sobrecarga deste método que não requerem o clientErrorCallback parâmetro definem o valor como nulo.
Para mais informações sobre este método, consulte as observações sobre o método de sobrecarga GetCallbackEventReference .
Ver também
Aplica-se a
GetCallbackEventReference(Control, String, String, String, String, Boolean)
Obtém uma referência a uma função cliente que, quando invocada, inicia uma chamada cliente de volta para eventos do servidor. A função cliente para este método sobrecarregado inclui um controlo especificado, argumento, script cliente, contexto, manipulador de erros e valor booleano especificados.
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
Parâmetros
- control
- Control
O servidor Control que gere o callback do cliente. O controlo deve implementar a ICallbackEventHandler interface e fornecer um RaiseCallbackEvent(String) método.
- argument
- String
Um argumento passado do script cliente para o método servidor RaiseCallbackEvent(String) .
- clientCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado do evento do servidor bem-sucedido.
- context
- String
O script do cliente que é avaliado no cliente antes de iniciar a chamada de retorno. O resultado do script é transmitido de volta ao gestor de eventos do cliente.
- clientErrorCallback
- String
O nome do gestor de eventos do cliente que recebe o resultado quando ocorre um erro no gestor de eventos do servidor.
- useAsync
- Boolean
true realizar o callback de forma assíncrona; false para realizar o callback de forma síncrona.
Devoluções
O nome de uma função cliente que invoca o callback do cliente.
Exceções
O Control especificado é null.
O Control especificado não implementa a ICallbackEventHandler interface.
Observações
Esta sobrecarga do GetCallbackEventReference método requer um parâmetro e useAsync um clientErrorCallback parâmetro. O useAsync parâmetro permite realizar o callback do cliente de forma assíncrona, definindo o valor para true. As versões de sobrecarga deste método que não requerem o useAsync parâmetro definem o valor por false defeito. O clientErrorCallback parâmetro permite-lhe definir o nome da função cliente que é chamada se o handler do servidor (o RaiseCallbackEvent método) devolver um erro. As versões de sobrecarga deste método que não requerem o clientErrorCallback parâmetro definem o valor como nulo.
Para mais informações sobre este método, consulte as observações sobre o método de sobrecarga GetCallbackEventReference .