ClientScriptManager.GetCallbackEventReference Metodo

Definizione

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client a un evento server.

Overload

GetCallbackEventReference(Control, String, String, String)

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client a un evento server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client e un contesto specificati.

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client, un contesto e un valore Boolean specificati.

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include una destinazione, un argomento, uno script client, un contesto, un gestore errori e un valore Boolean specificati.

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client, un contesto, un gestore errori e un valore Boolean specificati.

GetCallbackEventReference(Control, String, String, String)

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client a un evento server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client e un contesto specificati.

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

Parametri

control
Control

Server Control che gestisce il callback client. Il controllo deve implementare l'interfaccia ICallbackEventHandler e fornire un metodo RaiseCallbackEvent(String).

argument
String

Argomento passato al server dallo script client.

MetodoRaiseCallbackEvent(String) .

clientCallback
String

Nome del gestore eventi client che riceve il risultato dell'evento server riuscito.

context
String

Script client che viene valutato sul client prima di avviare il callback. Il risultato dello script viene restituito al gestore eventi client.

Restituisce

Nome di una funzione client che richiama il callback client.

Eccezioni

L’oggetto Control specificato è null.

L'oggetto Control specificato non implementa l'interfaccia ICallbackEventHandler.

Esempio

Nell'esempio di codice seguente viene illustrato come usare due overload del GetCallbackEventReference metodo in uno scenario di callback client che incrementa i numeri interi.

Vengono visualizzati due meccanismi di callback; la differenza tra di esse è l'uso del context parametro . Viene fornita una ReceiveServerData1 funzione di callback client usando il context parametro . Al contrario, la ReceiveServerData2 funzione di callback client è definita in un <script> blocco nella pagina. Un RaiseCallbackEvent metodo è il gestore del server che incrementa il valore passato e il GetCallbackResult metodo restituisce il valore incrementato come stringa. Se il RaiseCallbackEvent metodo restituisce un errore, viene chiamata la ProcessCallBackError funzione client.

<%@ 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>

Commenti

Il GetCallbackEventReference(Control, String, String, String) metodo esegue un callback fuori banda al server che rappresenta una versione modificata del ciclo di vita normale di una pagina. Per altre informazioni, vedere Implementazione dei callback client senza postback.

Nota

Quando il browser è Microsoft Internet Explorer (versione 5.0 o successiva), il meccanismo di callback dello script viene implementato tramite il Microsoft. L'oggetto COM XmlHttp e richiede che il browser sia impostato per eseguire controlli ActiveX. Per altri browser, viene usato un OGGETTO XMLHttpRequest usando il DOM (Document Object Model) locale del browser. Per verificare se un browser supporta i callback client, utilizzare la SupportsCallback proprietà . Per verificare se un browser supporta XML su HTTP, utilizzare la SupportsXmlHttp proprietà . Entrambe le proprietà sono accessibili tramite la Browser proprietà dell'oggetto intrinseco ASP.NET Request .

L'overload GetCallbackEventReference del GetCallbackEventReference metodo esegue un callback in modo sincrono usando XML su HTTP. Quando si inviano dati in modo sincrono in uno scenario di callback, i callback sincroni restituiscono immediatamente e non bloccano il browser. Nessun callback sincrono può essere eseguito contemporaneamente nel browser. Se viene generato un secondo callback sincrono mentre uno è attualmente in sospeso, il secondo callback sincrono annulla il primo e verrà restituito solo il secondo callback.

Per inviare i dati in modo asincrono, usare uno degli overload che accettano il useAsync parametro , ovvero un valore booleano che controlla questo comportamento. Nello scenario asincrono è possibile avere più callback in sospeso; tuttavia, l'ordine in cui restituiscono non è garantito che corrisponda all'ordine in cui sono stati avviati.

Inoltre, questo overload del GetCallbackEventReference metodo non specifica alcuna funzione client per gestire il caso di una condizione di errore generata dal RaiseCallbackEvent metodo . Per specificare un gestore di callback degli errori del client, usare uno degli overload che accetta il clientErrorCallback parametro .

Il GetCallbackEventReference(Control, String, String, String) metodo accetta un parametro stringa argument facoltativo e restituisce una stringa. Per passare o per ricevere più valori, concatenare rispettivamente i valori nella stringa di input o di restituzione.

Nota

Evitare di usare lo stato di visualizzazione nell'implementazione delle proprietà di pagina o controllo che devono essere aggiornate durante le operazioni di callback dello script. Se le proprietà devono superare le richieste di pagina, è possibile usare lo stato della sessione.

Vedi anche

Si applica a

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client, un contesto e un valore Boolean specificati.

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

Parametri

control
Control

Server Control che gestisce il callback client. Il controllo deve implementare l'interfaccia ICallbackEventHandler e fornire un metodo RaiseCallbackEvent(String).

argument
String

Argomento passato al server dallo script client.

MetodoRaiseCallbackEvent(String) .

clientCallback
String

Nome del gestore eventi client che riceve il risultato dell'evento server riuscito.

context
String

Script client che viene valutato sul client prima di avviare il callback. Il risultato dello script viene restituito al gestore eventi client.

useAsync
Boolean

true per eseguire il callback in modo asincrono; false per eseguire il callback in modo sincrono.

Restituisce

Nome di una funzione client che richiama il callback client.

Eccezioni

L’oggetto Control specificato è null.

L'oggetto Control specificato non implementa l'interfaccia ICallbackEventHandler.

Commenti

Questo overload del GetCallbackEventReference metodo richiede un useAsync parametro che consente di eseguire il callback client in modo asincrono impostando il valore su true. Le versioni di overload di questo metodo che non richiedono il parametro impostano il useAsync valore su false per impostazione predefinita.

Per altre informazioni su questo metodo, vedere le osservazioni relative al metodo di overload GetCallbackEventReference .

Vedi anche

Si applica a

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include una destinazione, un argomento, uno script client, un contesto, un gestore errori e un valore Boolean specificati.

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

Parametri

target
String

Nome di un server Control che gestisce il callback client. Il controllo deve implementare l'interfaccia ICallbackEventHandler e fornire un metodo RaiseCallbackEvent(String).

argument
String

Argomento passato al server dallo script client.

MetodoRaiseCallbackEvent(String) .

clientCallback
String

Nome del gestore eventi client che riceve il risultato dell'evento server riuscito.

context
String

Script client che viene valutato sul client prima di avviare il callback. Il risultato dello script viene restituito al gestore eventi client.

clientErrorCallback
String

Nome del gestore eventi client che riceve il risultato quando si verifica un errore nel gestore eventi server.

useAsync
Boolean

true per eseguire il callback in modo asincrono; false per eseguire il callback in modo sincrono.

Restituisce

Nome di una funzione client che richiama il callback client.

Esempio

Nell'esempio di codice seguente viene illustrato come usare due overload del GetCallbackEventReference metodo in uno scenario di callback client che incrementa i numeri interi.

Vengono visualizzati due meccanismi di callback; la differenza tra di esse è l'uso del context parametro . Viene fornita una ReceiveServerData1 funzione di callback client usando il context parametro . Al contrario, la ReceiveServerData2 funzione di callback client è definita in un <script> blocco nella pagina. Un RaiseCallbackEvent metodo è il gestore del server che incrementa il valore passato e il GetCallbackResult metodo restituisce il valore incrementato come stringa. Se il RaiseCallbackEvent metodo restituisce un errore, viene chiamata la funzione ProcessCallBackError client.

<%@ 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>

Commenti

Questo overload del GetCallbackEventReference metodo accetta un target parametro stringa anziché un Control parametro . Utilizzare questo overload quando si desidera che il callback torni a qualcosa di diverso da una stringa contenente l'oggetto UniqueID del controllo .

Inoltre, questo overload del GetCallbackEventReference metodo richiede un useAsync e un clientErrorCallback parametro . Il useAsync parametro consente di eseguire il callback client in modo asincrono impostando il valore su true. Le versioni di overload di questo metodo che non richiedono il parametro impostano il useAsync valore su false per impostazione predefinita. Il clientErrorCallback parametro consente di definire il nome della funzione client chiamata se il gestore del server, il RaiseCallbackEvent metodo , restituisce un errore. Le versioni di overload di questo metodo che non richiedono il clientErrorCallback parametro impostano il valore su Null.

Per altre informazioni su questo metodo, vedere le osservazioni relative al metodo di overload GetCallbackEventReference .

Vedi anche

Si applica a

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

Ottiene un riferimento a una funzione client che, quando richiamata, avvia un callback client agli eventi server. La funzione client per questo metodo di overload include un controllo, un argomento, uno script client, un contesto, un gestore errori e un valore Boolean specificati.

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

Parametri

control
Control

Server Control che gestisce il callback client. Il controllo deve implementare l'interfaccia ICallbackEventHandler e fornire un metodo RaiseCallbackEvent(String).

argument
String

Argomento passato dallo script client al metodo RaiseCallbackEvent(String) del server.

clientCallback
String

Nome del gestore eventi client che riceve il risultato dell'evento server riuscito.

context
String

Script client che viene valutato sul client prima di avviare il callback. Il risultato dello script viene restituito al gestore eventi client.

clientErrorCallback
String

Nome del gestore eventi client che riceve il risultato quando si verifica un errore nel gestore eventi server.

useAsync
Boolean

true per eseguire il callback in modo asincrono; false per eseguire il callback in modo sincrono.

Restituisce

Nome di una funzione client che richiama il callback client.

Eccezioni

L’oggetto Control specificato è null.

L'oggetto Control specificato non implementa l'interfaccia ICallbackEventHandler.

Commenti

Questo overload del GetCallbackEventReference metodo richiede un useAsync parametro e clientErrorCallback . Il useAsync parametro consente di eseguire il callback client in modo asincrono impostando il valore su true. Le versioni di overload di questo metodo che non richiedono il parametro impostano il useAsync valore su false per impostazione predefinita. Il clientErrorCallback parametro consente di definire il nome della funzione client chiamata se il gestore del server (il RaiseCallbackEvent metodo) restituisce un errore. Le versioni di overload di questo metodo che non richiedono il clientErrorCallback parametro impostano il valore su Null.

Per altre informazioni su questo metodo, vedere le osservazioni relative al metodo di overload GetCallbackEventReference .

Vedi anche

Si applica a