属性“CommandArgument”只写

发布于 2024-09-29 12:40:15 字数 483 浏览 7 评论 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 的。但是,我收到以下错误:

Property 'CommandArgument' is WriteOnly.

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

谢谢。

I have the following line in my code, inside the click event handler of an 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

Both Controls are ImageButton's. However, I'm getting the following error:

Property 'CommandArgument' is WriteOnly.

Can anyone see why I'm getting this error as usually I can read from a CommandArgument inside an event handler. In fact, surely thats their main use!

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

似狗非友 2024-10-06 12:40:15

您已为 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

You've wired up an event for EventArgs, but trying to retrieve CommandArgs.

This should be your method:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文