[vb.net] Aiuto errore The target '__Page' for the callback could.........

venerdì 10 ottobre 2008 - 00.00

ertulio Profilo | Senior Member

Salve, quando compilo la pagina web riscontro questo errore cosa significa?
The target '__Page' for the callback could not be found or did not implement ICallbackEventHandler

Grazie 1000
http://www.risorsefantacalcio.it

Risorse per tutti gli appassionati di fantacalcio da cui prelevare news, probabili formazioni, voti del corriere e gazzetta e tanhto altro.

balfaz Profilo | Expert

l'unico che mi viene in mente è che stai lavorando con questa voce all'inizio della tua pagina "<%@ Implements Interface='System.Web.UI.ICallbackEventHandler' %>" è per ciò in automatico lui cerca questo evento.

"Ci sono due tipi di pazzi, quelli che dicono pazzie e quelli che le fanno diventare una realtà."

ertulio Profilo | Senior Member

no, ho provato a mettere quella riga di codice, però mi da un errore e non mi fa fare debug
http://www.risorsefantacalcio.it

Risorse per tutti gli appassionati di fantacalcio da cui prelevare news, probabili formazioni, voti del corriere e gazzetta e tanhto altro.

PEPE Profilo | Senior Member

Ciao,
il problema potrebbe essere dovuto al fatto che nel code behind non hai implementato l'interfaccia.

Mi spiego subito. Se hai una pagina default.aspx, nel codebehind devi avere una cosa del genere
Partial Class _Default Inherits System.Web.UI.Page implements icallbackeventhandler

inoltre l'implementazione dell'interfaccia deve implementare anche i suoi metodi che sono getcallbackresults e RaiseCallbackEvent.

eccoti un esempio in c#
http://msdn.microsoft.com/en-us/library/ms178210(VS.80).aspx

ed uno in vb.net
http://msdn.microsoft.com/en-us/library/ms178209(VS.80).aspx

Ciao,
Luca.

ertulio Profilo | Senior Member

ciao, ho seguito l'esempio postato ma nulla, il codice che utilizzo è il seguente dove sbaglio???

Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO


Partial Class Oratorio
Inherits System.Web.UI.Page


Private m_lastFileName As String = "none"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If True Then
If IsPostBack Then
Return
End If

photo.Src = GetNextImageUrl()

'Register Ajax client script to client's browsers. This has to be hard coded.
Dim cbReference As String = Page.ClientScript.GetCallbackEventReference(Me, "arg", "ReceiveServerData", "context")
Dim callbackScript As String = "function CallServer(arg, context)" + "{ " + cbReference + "} ;"
Page.ClientScript.RegisterClientScriptBlock(Me.[GetType](), "CallServer", callbackScript, True)
End If

End Sub
Public Sub RaiseCallbackEvent(ByVal eventArgument As String)
'This is first place to receive the callback from client's browser. The parameter 'eventArgument'
'is the parameter passed from the Javascript's call 'CallServer()'. In this example, it is the
'last image url.
m_lastFileName = Path.GetFileName(eventArgument)
End Sub
Public Function GetCallbackResult() As String
'This is the second call triggled by the 'CallServer()' and it is the place to prepare and return a string
'to the client. Here the returned string is the image url and the transition effect.
Return GetNextImageUrl() + ";" + GetNextTransition()
End Function
Private Function GetNextImageUrl() As String
'Randomly pick a image file in the server.
Dim files As String() = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "images", "*.jpg")
If files.Length = 0 Then
Return String.Empty
End If

While True
Dim n As Integer = CInt(((files.Length - 1) * (New Random()).NextDouble()))
'Do not want to repeat the last image
If files(n).IndexOf(m_lastFileName) < 0 Then
Return files(n).Replace(AppDomain.CurrentDomain.BaseDirectory, String.Empty)
End If
End While
End Function

Private Function GetNextTransition() As String
'Randomly pick a transition effect. Note some of the effects only work in IE.
Dim n As Integer = CInt(((New Random().NextDouble()) * 5))
Select Case n
Case 0, 1
n = CInt(((New Random().NextDouble()) * 22))
Return "revealTrans(duration=2,transition=" + n.ToString() + ")"
Case 2, 3
If Request.Browser.Browser = "IE" Then
n = CInt(((New Random().NextDouble()) * 5))
Select Case n
Case 0
Return "progid:DXImageTransform.Microsoft.RandomDissolve()"
Case 1
Return "progid:DXImageTransform.Microsoft.Pixelate(MaxSquare=20,Duration=2,Enabled=false)"
Case 2
Return "progid:DXImageTransform.Microsoft.RadialWipe(wipeStyle='clock')"
Case 3
Return "progid:DXImageTransform.Microsoft.Wheel(spokes=4)"
Case 4

Return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='spin')"
Case Else
Return "progid:DXImageTransform.Microsoft.Stretch(stretchStyle='push')"
End Select
Else
Return "blendTrans(duration=2)"
End If
Case Else
Return "blendTrans(duration=2)"
End Select
End Function





End Class

http://www.risorsefantacalcio.it

Risorse per tutti gli appassionati di fantacalcio da cui prelevare news, probabili formazioni, voti del corriere e gazzetta e tanhto altro.

balfaz Profilo | Expert

prova ad aggiungere alle tue stringhe Sub e function

Public Sub RaiseCallbackEvent(ByVal eventArgument As String)
Public Sub RaiseCallbackEvent(ByVal eventArguments As String)


questo pezzettino

---Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent---

per farle diventare cosi, senza di questo sono semplicemente una funzione e una procedura ....


"Ci sono due tipi di pazzi, quelli che dicono pazzie e quelli che le fanno diventare una realtà."

PEPE Profilo | Senior Member

Partial Class Oratorio Inherits System.Web.UI.Page Implements ICallbackeventhandler

In vb appena aggiungi l'implementazione all'interfaccia automaticamente ti aggiunge i due metodi.

Vedrai che funziona.

ertulio Profilo | Senior Member

Se provo come specifica balsaz mi dice istruzione non valida all'interno di un metodo, se invece inserisco come dice pepe, ossia Partial Class Oratorio
Inherits System.Web.UI.Page
Implements ICallbackeventhandler

mi dice class oratorio deve implementare function getcallback results as string

dove sbaglio
http://www.risorsefantacalcio.it

Risorse per tutti gli appassionati di fantacalcio da cui prelevare news, probabili formazioni, voti del corriere e gazzetta e tanhto altro.

balfaz Profilo | Expert

guarda questo link

http://msdn.microsoft.com/en-us/library/ms178209(VS.80).aspx
"Ci sono due tipi di pazzi, quelli che dicono pazzie e quelli che le fanno diventare una realtà."

PEPE Profilo | Senior Member

Ciao,
cerchero di essere il piu semplice ed esplicativo possibile.

Per implementare le funzionalità delle callback devi implementare nella tua pagina un'interfaccia che si chiama ICallbackEventHandler
Il modo con cui si dice ad una classe di implementare un interfaccia è dato dall'utilizzo della parola chiave implements (in vb); quindi nel tuo caso avrai una cosa del genere
Partial Class Default Inherits System.Web.UI.Page Implements System.Web.UI.ICallbackEventHandler

Dato che stai implementando un'interfaccia, devi per forza (obbligatorio) implementare i suoi metodi.
L'interfaccia ICallbackEventHandler ha due metodi: RaiseCallbackEvent e GetCallbackResult.
Quindi nel tuo codebehind dovrai "creare" questi due metodi con la stessa firma dichiarata nell'interfaccia. La stessa firma vuol dire che il nome del metodo, i parametri in ingresso e quelli in uscita devono corrispondere.
Quindi avrai questa implementazione:
Il codice sorgente non è stato renderizzato qui
perchè non c'è sufficiente spazio.
Clicca qui per visualizzarlo in una nuova finestra

Saluti,
Luca.

Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5