Domanda

Ho la seguente riga nel mio codice, all'interno del gestore di eventi click di un ImageButton:

Protected Sub FinaliseBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles FinaliseBtn.Click, SubmitPaymentViaChequeBtn.Click
   Dim str as String = sender.commandargument.ToString.ToLower
End Sub

Entrambi i controlli sono ImageButton di. Tuttavia, sto ottenendo il seguente errore:

Property 'CommandArgument' is WriteOnly.

Qualcuno può vedere il motivo per cui sto ottenendo questo errore come di solito posso leggere da un CommandArgument all'interno di un gestore di eventi. In realtà, questo è sicuramente il loro uso principale!

Grazie.

È stato utile?

Soluzione

Hai cablata un evento per EventArgs , ma cercando di recuperare CommandArgs .

Questo dovrebbe essere il vostro metodo:

Sub ImageButton_Command(sender As Object, e As CommandEventArgs) 
         If (e.CommandName = "Sort") And (e.CommandArgument = "Ascending") Then
            Label1.Text = "You clicked the Sort Ascending Button"
         Else
            Label1.Text = "You clicked the Sort Descending Button"
         End If
      End Sub
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top