Property'CommandArgument'是WriteOnly

时间:2010-10-29 08:31:57

标签: asp.net event-handling asp.net-3.5 sender commandargument

我的代码中有以下行,位于ImageButton的click事件处理程序中:

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读取。事实上,这肯定是他们的主要用途!

感谢。

1 个答案:

答案 0 :(得分: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