Propriété « CommandArgument » est WriteOnly
-
27-09-2019 - |
Question
J'ai la ligne suivante dans mon code, à l'intérieur du gestionnaire d'événements d'un clic 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
Les deux contrôles sont ImageButton
de. Cependant, je reçois l'erreur suivante:
Property 'CommandArgument' is WriteOnly.
Quelqu'un peut-il voir pourquoi je reçois cette erreur que je peux habituellement lire un CommandArgument dans un gestionnaire d'événements. En fait, sûrement des thats leur utilisation principale!
Merci.
La solution
Vous avez câblé un événement pour EventArgs , mais en essayant de récupérer CommandArgs .
Cela devrait être votre méthode:
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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow