住宅“CommandArgument”是只写
-
27-09-2019 - |
题
我在我的以下代码行,一个的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
的。不过,我发现了以下错误:
Property 'CommandArgument' is WriteOnly.
任何人都可以看到,为什么我得到这个错误通常是因为我可以从事件处理程序内部的CommandArgument读取。事实上,这就是肯定他们的主要用途!
感谢。
解决方案
您已经连接好了事件的 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
不隶属于 StackOverflow