0

我的代码中有以下行,位于 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

两个控件都是ImageButton's。但是,我收到以下错误:

Property 'CommandArgument' is WriteOnly.

任何人都可以看到为什么我会收到此错误,因为通常我可以从事件处理程序中的 CommandArgument 中读取。事实上,这肯定是他们的主要用途!

谢谢。

4

1 回答 1

0

您已为EventArgs连接了一个事件,但试图检索CommandArgs

这应该是你的方法:

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
于 2010-10-29T09:41:42.143 回答